APC is using a lot of memory. On my server, ~30 Wordpress and 6 Magento websites, it is using more than 1GB wich is more than the size of PHP files.
I thought opcode would be smaller than the PHP files. As is a compiled JAVA compared to source.
For example, the index.php of Magento is 2571B on the disk and it uses 16560B in APC.
I don't use any user cache.
Any idea ?
The opcode caches each and every php file by the path that it's on. So that's 30 x every wordpress PHP file or 6 x each Magento PHP file. That's not to mention any PEAR libraries or others you might be using.
Also, what is your setting in your /etc/php.d/apc.ini or php.ini file for the memory to allow APC?
apc.shm_segments=1
apc.shm_size=256
Multiply segments times size and thats as large as APC will grow. It immediately takes this memory block to use, even if you're not really using it. Check your apc.php file to see the actual usage.
Looking at a Wordpress recent install of wordpress, I'm seeing at least 8M of just php files. So if you have 30 sites with their own full install of wordpress and using APC, that alone (without any plugins) would be a huge amount of stuff in the opcode cache.
In general opcode should be smaller than the file size, but you can't know for sure 100%. For example, checking APC.php in the system cache tab, I see this file being cached: /usr/share/pear/Zend/View/Abstract.php. I know on disk it is 33k, but APC reports it's using 20K of memory. If I had 2 copies of this file in two locations (like /usr/share/pear/Zend/View/Abstract.php and /usr/share/pear/Zend2/View/Abstract.php) and referenced both in different blocks of code, APC would cache each--it thinks they're different files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With