|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64624 Use a SLAB-style memory allocator to avoid fragmentation
Submitted: 2013-04-10 16:25 UTC Modified: 2013-04-11 04:17 UTC
From: martin dot langhoff at gmail dot com Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5.3.23 OS: Linux / RHEL6.3
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-04-10 16:25 UTC] martin dot langhoff at gmail dot com
Memory fragmentation in APC is a significant problem. Currently apc.php contains 
code to show fragmentation, and a recommendation is to deal with it by bouncing 
apache or calling apc_clear_cache() regularly.

These workarounds should not be needed with a simple slab-style memory allocator.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-04-10 16:58 UTC]
-Status: Open +Status: Wont fix
 [2013-04-10 16:58 UTC]
There won't be any major changes like that to APC. Development has moved to 
opcache. See
 [2013-04-10 17:48 UTC] martin dot langhoff at gmail dot com
Hi Rasmus - thanks for this info.

One more question (because APC will continue to see usage in PHP <5.5).

In order to have a good/better workaround for the current APC code, I would like 
to have good fragmentation stats. You wrote in
id=58510 that "The fragmentation calculation is a bit artificial and may need to 
be updated for 3.1.2 actually."

In SVN, the apc.php code has not seen changes to the fragmentation calc, so I 
guess that never happened. 

To be more explicit, I am working on the following simplified (pseudo)code:

function my_request_shutdown() {
    if (rand(1, 1000) === 1) { #
        fragmentation = code lifted from apc.php
        if (fragmentation > 80) {

If the fragmentation code in apc.php is busted, I'm interested in hints to improve 

Background -- this is for the rather popular Moodle LMS.

Thanks again ~
 [2013-04-10 22:00 UTC]
Are you actually seeing fragmentation issues? Forget what apc.php tells you, are 
you actually seeing performance degradation due to fragmentation? Honestly I have 
never been able to measure any degradation myself even when apc.php tells me the 
cache is highly fragmented.
 [2013-04-10 22:35 UTC] martin dot langhoff at gmail dot com
Yes, we have a busy Moodle installation showing a very significant slowdown in PHP 
execution. This is in a VM so the workload is well-defined: Moodle. All stats were 
normal, except the apc.php script indicating 100% fragmentation.

Apache graceful restart cured both the fragmentation report and the PHP execution 

Correlation is not causation, but it sure is a hint!
 [2013-04-11 04:17 UTC]
Increasing your segment size should help quite a bit then along with a graceful 
every couple of days. And note that opcache works quite well with PHP 5.4 as 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Sep 26 00:01:25 2023 UTC