* Only start recycling oschunks once MaxKeptOSChunks chuncks have

been allocated. E.g. allocate 100 blocks of 80 bytes and free them
    all, then the same with blocks of 96, 112, 128, 144, 160 and 176
    bytes, after which again 80 bytes -> previously, regardless of
    the value of MaxKeptOSChunks, the empty block for 80 bytes was
    reformatted for those of 96 bytes, then for 112 bytes etc. Now,
    if MaxKeptOSChunks is set to 7, none will ever be reformatted
    because enough chunks will be allocated from the OS.

git-svn-id: trunk@9696 -
This commit is contained in:
Jonas Maebe 2008-01-09 20:39:59 +00:00
parent 588822b14d
commit eb83213f10

View File

@ -729,6 +729,9 @@ begin
maxsize := 1 shl (32-fixedoffsetshift)
else
maxsize := high(ptruint);
poc:=nil;
if (loc_freelists^.oscount>=MaxKeptOSChunks) then
begin
{ blocks available in freelist? }
poc := find_free_oschunk(loc_freelists, minsize, maxsize, size);
if not assigned(poc) and (assigned(orphaned_freelists.waitfixed)
@ -760,6 +763,7 @@ begin
end;
leavecriticalsection(heap_lock);
end;
end;
if poc = nil then
begin
{$ifdef DUMPGROW}
@ -1050,7 +1054,7 @@ begin
end;
dec(loc_freelists^.internal_status.currheapused, chunksize);
{ insert the block in it's freelist }
{ insert the block in its freelist }
chunkindex := chunksize shr blockshift;
pmc_next := loc_freelists^.fixedlists[chunkindex];
pmc^.prev_fixed := nil;