Exemplo n.º 1
0
        private static bool StartNoGCRegionWorker(long totalSize, bool hasLohSize, long lohSize, bool disallowFullBlockingGC)
        {
            StartNoGCRegionStatus status = (StartNoGCRegionStatus)_StartNoGCRegion(totalSize, hasLohSize, lohSize, disallowFullBlockingGC);

            if (status == StartNoGCRegionStatus.AmountTooLarge)
            {
                throw new ArgumentOutOfRangeException(nameof(totalSize),
                                                      "totalSize is too large. For more information about setting the maximum size, see \"Latency Modes\" in http://go.microsoft.com/fwlink/?LinkId=522706");
            }
            else if (status == StartNoGCRegionStatus.AlreadyInProgress)
            {
                throw new InvalidOperationException("The NoGCRegion mode was already in progress");
            }
            else if (status == StartNoGCRegionStatus.NotEnoughMemory)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        private static bool StartNoGCRegionWorker(long totalSize, bool hasLohSize, long lohSize, bool disallowFullBlockingGC)
        {
            if (totalSize <= 0)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(totalSize),
                          SR.Format(SR.ArgumentOutOfRange_MustBePositive, nameof(totalSize)));
            }

            if (hasLohSize)
            {
                if (lohSize <= 0)
                {
                    throw new ArgumentOutOfRangeException(
                              nameof(lohSize),
                              SR.Format(SR.ArgumentOutOfRange_MustBePositive, nameof(lohSize)));
                }

                if (lohSize > totalSize)
                {
                    throw new ArgumentOutOfRangeException(nameof(lohSize), SR.ArgumentOutOfRange_NoGCLohSizeGreaterTotalSize);
                }
            }

            StartNoGCRegionStatus status =
                (StartNoGCRegionStatus)RuntimeImports.RhStartNoGCRegion(totalSize, hasLohSize, lohSize, disallowFullBlockingGC);

            switch (status)
            {
            case StartNoGCRegionStatus.NotEnoughMemory:
                return(false);

            case StartNoGCRegionStatus.AlreadyInProgress:
                throw new InvalidOperationException(SR.InvalidOperationException_AlreadyInNoGCRegion);

            case StartNoGCRegionStatus.AmountTooLarge:
                throw new ArgumentOutOfRangeException(nameof(totalSize), SR.ArgumentOutOfRangeException_NoGCRegionSizeTooLarge);
            }

            Debug.Assert(status == StartNoGCRegionStatus.Succeeded);
            return(true);
        }
Exemplo n.º 3
0
        private static bool StartNoGCRegionWorker(long totalSize, bool hasLohSize, long lohSize, bool disallowFullBlockingGC)
        {
            if (totalSize <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(totalSize), "totalSize can't be zero or negative");
            }

            if (hasLohSize)
            {
                if (lohSize <= 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(lohSize), "lohSize can't be zero or negative");
                }

                if (lohSize > totalSize)
                {
                    throw new ArgumentOutOfRangeException(nameof(lohSize), "lohSize can't be greater than totalSize");
                }
            }

            StartNoGCRegionStatus status = (StartNoGCRegionStatus)_StartNoGCRegion(totalSize, hasLohSize, lohSize, disallowFullBlockingGC);

            switch (status)
            {
            case StartNoGCRegionStatus.NotEnoughMemory:
                return(false);

            case StartNoGCRegionStatus.AlreadyInProgress:
                throw new InvalidOperationException("The NoGCRegion mode was already in progress");

            case StartNoGCRegionStatus.AmountTooLarge:
                throw new ArgumentOutOfRangeException(nameof(totalSize),
                                                      "totalSize is too large. For more information about setting the maximum size, see \"Latency Modes\" in http://go.microsoft.com/fwlink/?LinkId=522706");
            }

            Debug.Assert(status == StartNoGCRegionStatus.Succeeded);
            return(true);
        }
Exemplo n.º 4
0
        private static bool StartNoGCRegionWorker(long totalSize, bool hasLohSize, long lohSize, bool disallowFullBlockingGC)
        {
            StartNoGCRegionStatus status =
                (StartNoGCRegionStatus)RuntimeImports.RhStartNoGCRegion(totalSize, hasLohSize, lohSize, disallowFullBlockingGC);

            if (status == StartNoGCRegionStatus.AmountTooLarge)
            {
                throw new ArgumentOutOfRangeException(
                          nameof(totalSize),
                          SR.ArgumentOutOfRangeException_NoGCRegionSizeTooLarge);
            }
            else if (status == StartNoGCRegionStatus.AlreadyInProgress)
            {
                throw new InvalidOperationException(
                          SR.InvalidOperationException_AlreadyInNoGCRegion);
            }
            else if (status == StartNoGCRegionStatus.NotEnoughMemory)
            {
                return(false);
            }

            return(true);
        }