-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instead of picking the first fitting block, check if there is a smaller block that still fits. We only look at a limited, small number of additional blocks. This is an approximation of best-fit allocation. This is intended to reduce fragmentation, in particular for the case where a large block was recently freed (and is on top of the free list) and a small allocation is performed.
- Loading branch information
Showing
2 changed files
with
76 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--TEST-- | ||
Test SMA behavior #1 | ||
--INI-- | ||
apc.enabled=1 | ||
apc.enable_cli=1 | ||
apc.shm_size=16M | ||
--FILE-- | ||
<?php | ||
|
||
// Make sure that a sequence of alternating small and large | ||
// allocations does not result in catastrophic fragmentation | ||
|
||
$len = 1024 * 1024; | ||
for ($i = 0; $i < 100; $i++) { | ||
apcu_delete("key"); | ||
$result = apcu_store("key", str_repeat("x", $len)); | ||
if ($result === false) { | ||
echo "Failed $i.\n"; | ||
} | ||
|
||
// Force a small allocation | ||
apcu_store("dummy" . $i, null); | ||
|
||
// Increase $len slightly | ||
$len += 100; | ||
} | ||
|
||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |