mlewisct Posted March 18, 2013 Share Posted March 18, 2013 I have a Joomla Site where users authenticate, then they can link to an online game that is not a Joomla component - just a PHP program. When I examine the processes running on the server, I see several and all show memory usage around 87MB. Since I don't store very much in the session - only a few keys, I don't know why memory usage should be so high for the process, nor can I tell from the process list if these are the game PHP program, or the Joomla session. What determines the size of a PHP process (in memory)? Is there an easy way to tell if the process is the game or the Joomla session? I am very limited in what I can see due to GoDaddy shared hosting. Quote Link to comment https://forums.phpfreaks.com/topic/275817-size-of-php-process/ Share on other sites More sharing options...
Jessica Posted March 18, 2013 Share Posted March 18, 2013 Moving this since your question is not with specific code help. Quote Link to comment https://forums.phpfreaks.com/topic/275817-size-of-php-process/#findComment-1419350 Share on other sites More sharing options...
kicken Posted March 18, 2013 Share Posted March 18, 2013 Use something like memory_get_usage to determine how much memory your scripts are using, rather than look at something like the output of top (or other process list). The amount of memory reported by a process listing program can be mis-leading do to how things like shared libraries work. For example the PHP engine will need memory for the PHP executable itself + all the loaded extensions (GD, Mysql, Zip, etc). When you run multiple instances of PHP though, they all references the same shared library code, so only the core php executable gets duplicated and needs more memory. A process listing would show both as if they each had their own copy of the libraries loaded though. Just to maybe help explain better, lets throw some theoretical numbers in: Say your PHP executable needs 10MB of memory to be loaded and run. When it runs, it loads the following extensions w/ their own memory requirements: GD: 4MB MySQL: 7MB Zip: 3MB PDO: 9MB So the first instance of PHP that gets run needs to load up itself + the libraries into RAM, requiring a total of 33MB of memory. This is what would be reported by a tool like top that lists processes. The second instance of PHP you start needs to load a second copy of the PHP executable into RAM, but it can reference the already existing copies of the libraries. As such it only requires an additional 10MB of memory to run. A tool like top would still report it as using 33MB of memory though, counting the libraries again. So if you checked the process list you'd see two instances of PHP each using 33MB of memory for a total of 66MB used. In reality though there is only 43MB of memory being used, since the shared libraries are, as the name implies, shared between the two processes. Quote Link to comment https://forums.phpfreaks.com/topic/275817-size-of-php-process/#findComment-1419366 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.