예제 #1
0
        private static void GcCollect(GarbageCollection garbageCollectionSettings)
        {
            if (garbageCollectionSettings != null && !garbageCollectionSettings.Force)
            {
                return;
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
        }
예제 #2
0
        private string SetGarbageCollectionSettings(string content, GarbageCollection garbageCollection)
        {
            if (garbageCollection == null || garbageCollection == GarbageCollection.Default)
            {
                return(content.Replace("$GC$", null));
            }

            return(content.Replace(
                       "$GC$",
                       $"\"runtimeOptions\": {{ \"configProperties\": {{ \"System.GC.Concurrent\": {garbageCollection.Concurrent.ToString().ToLower()}, \"System.GC.Server\": {garbageCollection.Server.ToString().ToLower()} }} }}, "));
        }
        private static void GenerateGCSettings(XmlDocument xmlDocument, XmlNode runtimeElement, GarbageCollection garbageCollection)
        {
            if (garbageCollection == null || garbageCollection == GarbageCollection.Default)
            {
                return;
            }

            CreateNodeWithAttribute(xmlDocument, runtimeElement, "gcConcurrent", "enabled", garbageCollection.Concurrent.ToString().ToLower());
            CreateNodeWithAttribute(xmlDocument, runtimeElement, "gcServer", "enabled", garbageCollection.Server.ToString().ToLower());
            CreateNodeWithAttribute(xmlDocument, runtimeElement, "GCCpuGroup", "enabled", garbageCollection.CpuGroups.ToString().ToLower());
            CreateNodeWithAttribute(xmlDocument, runtimeElement, "gcAllowVeryLargeObjects", "enabled", garbageCollection.AllowVeryLargeObjects.ToString().ToLower());
        }
예제 #4
0
    public void OnDisable()
    {
        m_Inst = null;
        for (eFruitType type = eFruitType.Fruit_Melon; type <= eFruitType.Fruit_Size; type++)
        {
            if (m_dGCList.ContainsKey(type))
            {
                List <GameObject> list = m_dGCList[type];
                list.Clear();
                list = null;
            }
        }

        m_dGCList = null;
    }
예제 #5
0
        static void Main(string[] args)
        {
            SmallTests st = new SmallTests();

            st.StructVsEnum();

            NewStruct ns = new NewStruct();

            ns.create();

            GarbageCollection gc = new GarbageCollection();
            //gc.start();

            Strings s = new Strings();

            s.Start();

            Console.ReadLine();
        }
예제 #6
0
파일: Main.cs 프로젝트: Colean128/blu-ray
        internal async Task RunAsync(Configuration configuration, int shardId, int shardCount, string dbPath)
        {
            LogLevel level;

            switch (configuration.LogLevel.ToLower())
            {
            case "debug":
                level = LogLevel.Debug;
                break;

            case "warning":
                level = LogLevel.Warning;
                break;

            case "error":
                level = LogLevel.Error;
                break;

            case "critical":
                level = LogLevel.Critical;
                break;

            default:
                level = LogLevel.Info;
                break;
            }

            client = new DiscordClient(new DiscordConfiguration
            {
                AutoReconnect         = true,
                LogLevel              = level,
                Token                 = configuration.Token,
                TokenType             = TokenType.Bot,
                ShardCount            = shardCount,
                ShardId               = shardId,
                UseInternalLogHandler = true
            });

            Events.supportGuildId = configuration.SupportId;

            client.Ready          += Events.OnClientReady;
            client.Resumed        += Events.OnClientResumed;
            client.ClientErrored  += Events.OnClientError;
            client.SocketErrored  += Events.OnClientSocketError;
            client.GuildAvailable += Events.OnGuildJoin;
            client.GuildCreated   += Events.OnGuildJoin;
            client.GuildDeleted   += Events.OnGuildLeave;

            client.MessageCreated += AFK.AFKMessageHandler;

            client.MessageReactionAdded        += Starboard.ReactionAddHandler;
            client.MessageReactionRemoved      += Starboard.ReactionRemoveHandler;
            client.MessageReactionRemovedEmoji += Starboard.ReactionRemoveEmojiHandler;
            client.MessageReactionsCleared     += Starboard.ReactionRemoveAllHandler;

            commands = client.UseCommandsNext(new CommandsNextConfiguration
            {
                CaseSensitive        = true,
                EnableDefaultHelp    = true,
                EnableDms            = true,
                EnableMentionPrefix  = true,
                IgnoreExtraArguments = true,
                StringPrefixes       = configuration.Prefixes,
            });

            commands.SetHelpFormatter <Help>();

            commands.CommandExecuted += Events.OnCommandExecute;
            commands.CommandErrored  += Events.OnCommandError;

            commands.RegisterCommands <Fun>();
            commands.RegisterCommands <Info>();
            commands.RegisterCommands <Moderation>();
            commands.RegisterCommands <NSFW>();
            commands.RegisterCommands <Owner>();
            commands.RegisterCommands <Search>();
            //commands.RegisterCommands<Settings>();

            client.UseInteractivity(new InteractivityConfiguration
            {
                PaginationBehaviour = PaginationBehaviour.Ignore,
                PaginationDeletion  = PaginationDeletion.DeleteEmojis,
                PollBehaviour       = PollBehaviour.DeleteEmojis
            });

            IMDb.InitializeWithKey(configuration.OMDb);
            Managers.Google.InitializeService(configuration.Google.Key, configuration.Google.Cx);

            await Spotify.AuthorizeAsync(configuration.Spotify.ID, configuration.Spotify.Secret, client.DebugLogger);

            await Database.ConnectAsync(dbPath, client.DebugLogger);

            garbage = new GarbageCollection();

            AppDomain.CurrentDomain.ProcessExit += new EventHandler((s, e) => HandleProcessQuit().GetAwaiter().GetResult());

            Emojis.Initialize(configuration.Emojis.Success,
                              configuration.Emojis.Warning,
                              configuration.Emojis.Error,
                              configuration.Emojis.Online,
                              configuration.Emojis.Idle,
                              configuration.Emojis.DoNotDisturb,
                              configuration.Emojis.Offline);

            await client.ConnectAsync(new DiscordActivity(configuration.Status.Name, configuration.Status.Type));

            await Task.Delay(-1);
        }
        private string SetGarbageCollectionSettings(string content, GarbageCollection garbageCollection)
        {
            if (garbageCollection == null || garbageCollection == GarbageCollection.Default)
            {
                return content.Replace("$GC$", null);
            }

            return content.Replace(
                "$GC$",
                $"\"runtimeOptions\": {{ \"configProperties\": {{ \"System.GC.Concurrent\": {garbageCollection.Concurrent.ToString().ToLower()}, \"System.GC.Server\": {garbageCollection.Server.ToString().ToLower()} }} }}, ");
        }
예제 #8
0
 public static IJob With(this IJob job, GarbageCollection garbageCollection) => job.With(j => j.GarbageCollection = garbageCollection);
예제 #9
0
        private Measurement MultiInvoke <T>(IterationMode mode, int index, Action setupAction, Func <T> targetAction, Action cleanupAction, long invocationCount, long operationsPerInvoke, GarbageCollection garbageCollectionSettings, T returnHolder = default(T))
        {
            var totalOperations = invocationCount * operationsPerInvoke;

            setupAction();
            ClockSpan clockSpan;

            GcCollect(garbageCollectionSettings);
            if (invocationCount == 1)
            {
                var chronometer = Chronometer.Start();
                returnHolder = targetAction();
                clockSpan    = chronometer.Stop();
            }
            else if (invocationCount < int.MaxValue)
            {
                int intInvocationCount = (int)invocationCount;
                var chronometer        = Chronometer.Start();
                RunAction(targetAction, intInvocationCount);
                clockSpan = chronometer.Stop();
            }
            else
            {
                var chronometer = Chronometer.Start();
                RunAction(targetAction, invocationCount);
                clockSpan = chronometer.Stop();
            }
            multiInvokeReturnHolder = returnHolder;
            var measurement = new Measurement(0, mode, index, totalOperations, clockSpan.GetNanoseconds());

            Console.WriteLine(measurement.ToOutputLine());
            GcCollect(garbageCollectionSettings);
            return(measurement);
        }
예제 #10
0
        private static void GenerateGCSettings(XmlDocument xmlDocument, XmlNode runtimeElement, GarbageCollection garbageCollection)
        {
            if (garbageCollection == null || garbageCollection == GarbageCollection.Default)
            {
                return;
            }

            CreateNodeWithAttribute(xmlDocument, runtimeElement, "gcConcurrent", "enabled", garbageCollection.Concurrent.ToString().ToLower());
            CreateNodeWithAttribute(xmlDocument, runtimeElement, "gcServer", "enabled", garbageCollection.Server.ToString().ToLower());
            CreateNodeWithAttribute(xmlDocument, runtimeElement, "GCCpuGroup", "enabled", garbageCollection.CpuGroups.ToString().ToLower());
            CreateNodeWithAttribute(xmlDocument, runtimeElement, "gcAllowVeryLargeObjects", "enabled", garbageCollection.AllowVeryLargeObjects.ToString().ToLower());
        }
예제 #11
0
 private void OnEnable()
 {
     m_Inst    = this;
     m_dGCList = new Dictionary <eFruitType, List <GameObject> >();
 }
예제 #12
0
        /// <summary>
        /// Called during startup by each shared project
        /// </summary>
        public static void Initialize(string environment)
        {
            //Initialize all static settings classes based on current environment
            //See "instructions.txt" for details  on the configurations to use per environment.
            //Host application must pass in the current environment name to initialize settings


            Environment.Current = environment;



            //---------------------------------------------------------------------

            //URLs & Email Addresses are initialized first as they are used in copy within other settings

            // Endpoint Settings ---------------
            URLs.Initialize();
            Emails.Initialize();


            //---------------------------------------------------------------------

            // Remaining settings are then initialized...

            // AZURE Services -----------------
            Databases.Initialize();
            DocumentDB.Initialize();
            Redis.Initialize();
            Storage.Initialize();
            Search.Initialize();

            // EXTERNAL Services ---------------
            Stripe.Initialize();
            SendGrid.Initialize();
            MailChimp.Initialize();
            GoogleMaps.Initialize();
            CloudFlare.Initialize();

            Registration.Initialize();
            GarbageCollection.Initialize();
            Custodian.Initialize();
            Worker.Initialize();
            Partitioning.Initialize();
            Payments.Initialize();

            // Platform Settings ---------------
            Application.Initialize();
            Platform.Users.Initialize();
            Accounts.Users.Initialize();
            Commerce.Credits.Initialize();

            //Copy Settings ---------------
            EmailMessages.Initialize();
            NotificationMessages.Initialize();
            PlatformMessages.Initialize();

            //Image Settings ------------
            Imaging.Images.Initialize();


            // Flush ALL Redis caches when we initialize CoreServices
            // This allows new updates to be forced into cached objects
            var redisEndpoints = Sahara.Core.Settings.Azure.Redis.RedisMultiplexers.RedisMultiplexer.GetEndPoints(true);
            var redisserver    = Sahara.Core.Settings.Azure.Redis.RedisMultiplexers.RedisMultiplexer.GetServer(redisEndpoints[0]);

            try
            {
                redisserver.FlushAllDatabases();
            }
            catch (Exception e)
            {
                string exception = e.Message;
            }


            /*
             * // Flush ALL Redis caches when we initialize CoreServices
             * // This allows new updates to be forced into cached objects
             * var accountsRedisEndpoints = Sahara.Core.Settings.Azure.Redis.RedisMultiplexers.AccountManager_Multiplexer.GetEndPoints(true);
             * var accountRedisserver = Sahara.Core.Settings.Azure.Redis.RedisMultiplexers.AccountManager_Multiplexer.GetServer(accountsRedisEndpoints[0]);
             * accountRedisserver.FlushAllDatabases();
             *
             * var platformRedisEndpoints = Sahara.Core.Settings.Azure.Redis.RedisMultiplexers.PlatformManager_Multiplexer.GetEndPoints(true);
             * var platformRedisserver = Sahara.Core.Settings.Azure.Redis.RedisMultiplexers.PlatformManager_Multiplexer.GetServer(platformRedisEndpoints[0]);
             * platformRedisserver.FlushAllDatabases();
             */
        }