Exemplo n.º 1
0
 private void GlobalInit()
 {
     error = "创建内存监视对象";
     GlobaCacherlInitializer.Init(_session);
     _startProgress.PrintStartInfo("正在创建内存监视对象......");
     MemoryIsEnoughChecker._session = _session;
     Parallel.Invoke(() => { PerformanceMonitoring.GetAvailableRAM(); });
 }
Exemplo n.º 2
0
 /// <summary>
 /// 初始化起始行、起始列
 /// </summary>
 /// <param name="startRowIndex"></param>
 /// <param name="startColumnIndex"></param>
 public ExcelGlobalDTO(int startRowIndex = 0, int startColumnIndex = 0)
 {
     ExcelValidationMessage = new ExcelValidationMessage();
     PerformanceMonitoring  = new PerformanceMonitoring();
     GlobalStartRowIndex    = startRowIndex;
     GlobalStartColumnIndex = startColumnIndex;
     Sheets = new List <ExcelSheetModel <TEntity> >();
 }
Exemplo n.º 3
0
        private bool CheckMemory(string strRasName)
        {
            float availableSize = PerformanceMonitoring.GetAvailableRAM();

            if (availableSize < 0)
            {
                return(true);
            }
            int   memoryOfTile, tileCount;
            float requiredSize = RasterDrawing.EstimateRequiredMemory(strRasName, out memoryOfTile, out tileCount);

            IRasterDataProvider prd = GeoDataDriver.Open(strRasName) as IRasterDataProvider;
            int          nHeight    = prd.Height;
            int          nWidth     = prd.Width;
            enumDataType dataType   = prd.DataType;
            int          nByteCount = DataTypeHelper.SizeOf(dataType);

            requiredSize = requiredSize * 2 + nByteCount * nHeight * nWidth / 1024 / 1024;

            if (availableSize < requiredSize + 200)//预留200MB
            {
                return(false);
            }
            else                //内存碎片的可能性非常大,需要先尝试内存申请能否成功
            {
                for (int i = 0; i < tileCount; i++)
                {
                    try
                    {
                        byte[] tileBuffer = new byte[memoryOfTile];
                    }
                    catch
                    {
                        return(false);
                    }
                }

                try
                {
                    byte[] dataBuffer = new byte[nByteCount * nHeight * nWidth];
                }
                catch
                {
                    return(false);
                }

                return(true);
            }
        }
Exemplo n.º 4
0
        public static bool MemoryIsEnoughForRaster(string rasterFileName)
        {
            float availableSize = PerformanceMonitoring.GetAvailableRAM();

            if (availableSize < 0)
            {
                return(true);
            }
            int   memoryOfTile, tileCount;
            float requiredSize    = RasterDrawing.EstimateRequiredMemory(rasterFileName, out memoryOfTile, out tileCount);
            int   countOfDrawing  = 0;
            float memoryOfLoading = GetMemoryOfTileLoading(out countOfDrawing);

            //Console.WriteLine("AvailableSize:" + availableSize.ToString() + " , RequiredSize:" + requiredSize.ToString() + " , SizeOfLoading:" + memoryOfLoading.ToString());
            availableSize -= memoryOfLoading;
            int host_min_mem_size = HOST_MIN_MEMORY_SIZE;

            if (countOfDrawing == 0)
            {
                host_min_mem_size = 0;
            }
            if (availableSize < requiredSize + host_min_mem_size)//预留200MB
            {
                return(false);
            }
            else if (availableSize < requiredSize)//内存碎片的可能性非常大,需要先尝试内存申请能否成功
            {
                for (int i = 0; i < tileCount; i++)
                {
                    try
                    {
                        byte[] tileBuffer = new byte[memoryOfTile];
                    }
                    catch
                    {
                        Console.WriteLine("内存空间足够,但因内存碎片无法申请成功空间。");
                        return(false);
                    }
                }
                return(true);
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 5
0
        private const int HOST_MIN_MEMORY_SIZE = 200;//MB

        public static bool MemoryIsEnoughForVector(string vectorFileName)
        {
            if (CodeCell.AgileMap.Core.GlobalCacher.VectorDataGlobalCacher.GetData(vectorFileName) != null)
            {
                return(true);
            }
            float availableSize = PerformanceMonitoring.GetAvailableRAM();

            if (availableSize < 0)
            {
                return(true);
            }
            FileInfo fInfo        = new FileInfo(vectorFileName);
            float    requiredSize = 10 * fInfo.Length / 1024f / 1024f; //矢量文件大小的10倍

            if (availableSize < requiredSize)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 6
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public ExcelGlobalDTO()
 {
     ExcelValidationMessage = new ExcelValidationMessage();
     PerformanceMonitoring  = new PerformanceMonitoring();
     Sheets = new List <ExcelSheetModel <TEntity> >();
 }