I have apc.shm_size
set to 64M, the total number of php files (byte codes) is more than 64M, and I have used apc for shared variables.
Is it possible to define the size of memory so that the region for shared memory is independent of the bytecode cache? (otherwise they will be overwritten by the bytecode cache very soon)
the simple answer is no...
I solved using memcache for shared memory and apc for the byte codes cache.
For me the best solution for shared variables in PHP is using Redis.
The problem of sharing variables with APC is when your application scale in a cluster, with APC you only shared data in one machine, with Redis you can share data throughout the cluster.
Redis is an open source key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
Assuming you only have one webserver, you could achieve this by using different extensions for opcode and userland caching. Use Zend OPcache for the former, and APCu for the latter. OPCache is bundled with PHP 5.5 but you can install it with earlier versions (minimum is 5.2).