Sub Class_Globals
Private tmrHook As Timer
Private gcTime As Long
Private freq_gc As Int = 1
Private freq_info As Int = 10
Private Counter As Int
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
' 3 seconds
tmrHook.Initialize("tmrHook", 3000)
tmrHook.Enabled = True
#if debug
freq_info = 1
#End If
' set the initial GC time
gcTime =DateTime.Now + (DateTime.TicksPerMinute * freq_gc)
StartMessageLoop '<- don't forget!
End Sub
Sub tmrHook_Tick()
' do GC
If gcTime < DateTime.Now Then
' set next time
gcTime =DateTime.Now + (DateTime.TicksPerMinute * freq_gc)
process_gc
End If
End Sub
Sub process_gc()
Counter = Counter + 1
If Counter = freq_info Then
Log("Running Info Collector...")
Counter = 0
Dim variables As List
variables.Initialize
variables.Add(0)
variables.Add(0)
variables.Add(8)
variables.Add("Info Collection " & Main.ClientID)
variables.Add(FormatDateTimeNow3)
variables.Add(0)
Dim MB As Long = 1024 * 1024
variables.Add(DBM.pool.MemoryUsed / MB)
variables.Add(DBM.pool.MemoryAllocatedFree / MB)
variables.Add(DBM.pool.activeConnections)
variables.Add(DBM.pool.ThreadsAwaitingConnection)
variables.Add(DBM.pool.totalConnections - DBM.pool.activeConnections)
Dim SQL As SQL = DBM.GetSQL
Dim SQL_str As String = $"INSERT INTO tsys_Trace(OTID, trcLoginID, trcTrcTypID, trcInfo, trcDateTime, trcLinkID, trcMemUsed, trcMemAllocFree, trcActiveConnections, trcThreadsAwaitingConnection, trcFreeConnections) VALUES (?,?,?,?,?,?,?,?,?,?,?)"$
SQL.ExecNonQuery2(SQL_str, variables)
DBM.CloseSQL(SQL)
End If
Log("Running Garbage Collector...")
Dim jo As JavaObject = Me
jo.RunMethod("do_garbage_collection",Null)
End Sub
Public Sub FormatDateTimeNow3() As String
Dim orig As String = DateTime.DateFormat
DateTime.dateformat = "yyyy-MM-dd'T'HH:mm:ss"
Dim ret As String = DateTime.Date(DateTime.now)
DateTime.dateformat = orig
Return ret
End Sub
#if java
import java.util.*;
public void do_garbage_collection() {
Runtime rs = Runtime.getRuntime();
rs.gc();
}
#End If