浏览代码

* heap manager: fix shrinking var sized chunks to very small sizes < sizeof(tmemchunk_var)
was no problem previously due to sizeof(tmemchunk_var) <= blocksize

git-svn-id: trunk@7464 -

micha 18 年之前
父节点
当前提交
f9d2ea7e3a
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      rtl/inc/heap.inc

+ 7 - 1
rtl/inc/heap.inc

@@ -1226,7 +1226,13 @@ begin
       exit;
       exit;
     end;
     end;
 
 
-  { var memchunck }
+  { var memchunk }
+
+  { do not fragment the heap with small shrinked blocks }
+  {  also solves problem with var sized chunks smaller than sizeof(tmemchunk_var) }
+  if size < maxblocksize div 2 then
+    exit(false);
+
   currsize := chunksize and sizemask;
   currsize := chunksize and sizemask;
   size := (size+sizeof(tmemchunk_var_hdr)+(blocksize-1)) and sizemask;
   size := (size+sizeof(tmemchunk_var_hdr)+(blocksize-1)) and sizemask;