Kaynağa Gözat

* patch from Ales Katona making the memory manager more
smart when releasing memory chunks back to the OS

git-svn-id: trunk@190 -

florian 20 yıl önce
ebeveyn
işleme
0d7aaab6b8
2 değiştirilmiş dosya ile 4 ekleme ve 1 silme
  1. 2 1
      rtl/inc/heap.inc
  2. 2 0
      rtl/inc/heaph.inc

+ 2 - 1
rtl/inc/heap.inc

@@ -642,7 +642,8 @@ procedure append_to_oslist(poc: poschunk);
 begin
   { decide whether to free block or add to list }
 {$ifdef HAS_SYSOSFREE}
-  if freeoslistcount >= 3 then
+  if (freeoslistcount >= MaxKeptOSChunks)
+  or (poc^.size > growheapsize2) then
     begin
       dec(internal_status.currheapsize, poc^.size);
       SysOSFree(poc, poc^.size);

+ 2 - 0
rtl/inc/heaph.inc

@@ -76,6 +76,8 @@ procedure SetMemoryMutexManager(var MutexMgr: TMemoryMutexManager);
 
 { Variables }
 const
+  MaxKeptOSChunks: DWord = 3; { if more than MaxKeptOSChunks are free, the heap manager will release
+                              chunks back to the OS }
   growheapsizesmall : ptrint=32*1024; { fixed-size small blocks will grow with 32k }
   growheapsize1 : ptrint=256*1024;  { < 256k will grow with 256k }
   growheapsize2 : ptrint=1024*1024; { > 256k will grow with 1m }