5

Is it possible to de-fragment a APC cache or the only available option is to clear and rebuild it?
If we can't de-fragment it, is it a good idea to dump an entire cache clear it and then reload the dump? will this clear the fragmentation?

hakre
  • 193,403
  • 52
  • 435
  • 836
Uday Sawant
  • 5,748
  • 3
  • 32
  • 45
  • [What is your operating system?](http://geekblog.oneandoneis2.org/index.php/2006/08/17/why_doesn_t_linux_need_defragmenting) – hakre May 04 '12 at 14:36
  • @hakre, The problem is fragmentation reduces the number of stored files. currently I have around 12M/64M free space, totally fragmented, and the cache full count is at 12 in just 2 days. the stored files count had reduced to 360 from 510+. so i thought, it would be good if i can de-fragment the space at some interval. – Uday Sawant May 06 '12 at 17:29

3 Answers3

7

APC store opcodes in ram. It has no fragmentation management.

The only way to deframent is to flush cache. Use apc_clear_cache() in php script. Or restart httpd.

Note that APC will have to rebuild its cache.

There should be no (or few) fragmentation if you give APC enough memory. Check my answer here to see how to guess the required ram What is causing "Unable to allocate memory for pool" in PHP?

Community
  • 1
  • 1
bokan
  • 3,601
  • 2
  • 23
  • 38
0

There is alternative way. If you install somewhere file called apc.php with password (very important!) you can login on that site and flush opcode and user caches from there.

Harry
  • 253
  • 5
  • 11
-1

On Debian 8, install APC:

sudo apt-get install -y php5-apcu

Then copy apc.php into your web root:

cp /usr/share/doc/php5-apcu/apc.php /var/www/html

Edit the file, modifying the ADMIN_USERNAME & ADMIN_PASSWORD.

Then visit the apc.php file in your browser, login, & hit Clear Cache.

Lysergia25
  • 134
  • 2
  • 6