52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Linq;
|
|
|
|
//using BCG.Utilities;
|
|
//using BCG.Utilities.General;
|
|
|
|
|
|
namespace BCG {
|
|
class PubSub2Main {
|
|
|
|
/// <summary>
|
|
/// The main entry point for the application.
|
|
/// </summary>
|
|
[STAThread]
|
|
public static async Task Main(string[] args) {
|
|
bts.utils.BTSNativeMethods.provide_command_line(new string[] { }, 0);
|
|
mbts.config.Configuration.initialize();
|
|
// SimpleTCPServerAsync.start();
|
|
// Task.Delay(1000000000).Wait();
|
|
if (args.Length > 0 && args[0] == "daemon")
|
|
args = args.Skip(1).ToArray();
|
|
|
|
//CoreServicesInit.init();
|
|
PubSub3Config config = PubSub3Config.instance;
|
|
|
|
long currentMemory = 0;
|
|
int defaultWaitTime = 100;
|
|
bool gced = false;
|
|
new Thread(() => {
|
|
while (true) {
|
|
gced = false;
|
|
currentMemory = GC.GetTotalMemory(false);
|
|
if (config.PS3_GCActivationThreshold > 0 && currentMemory > config.PS3_GCActivationThreshold) {
|
|
string gcMsg = String.Format("GCing memory, mem before GC = {0}", currentMemory);
|
|
// BlueEventLog.logEvent(gcMsg, PS3LogLevels.info);
|
|
Console.WriteLine(gcMsg);
|
|
GC.Collect();
|
|
gced = true;
|
|
}
|
|
Thread.Sleep(gced ? config.PS3_WaitPeriodAfterGC : defaultWaitTime);
|
|
}
|
|
}).Start();
|
|
|
|
PubSubMessageReactor pubSubServer = new PubSubMessageReactor();
|
|
pubSubServer.start();
|
|
|
|
}
|
|
}
|
|
}
|