Reducing memory usage - Printable Version +- ispCP - Board - Support (http://www.isp-control.net/forum) +-- Forum: ispCP Omega Support Area (/forum-30.html) +--- Forum: Usage (/forum-34.html) +--- Thread: Reducing memory usage (/thread-10288.html) |
Reducing memory usage - pete - 04-07-2010 11:27 AM I'm using way more memory than is allocated for me by the virtual machine hosting service (limit is 512MB with 1024MB burst). I checked what is running using the top command and found that I have two large apache2 instances, each clobbering 277MB. Why two? Also, MySQL should have very little work to do but still uses 144MB. Am I doing something wrong? Can I force these processes to be more frugal? Note that unfortunately I can't create a swap disk or file, the VPS doesn't support that. Following is what top tells me (sorted by memory usage): Code: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND RE: Reducing memory usage - BeNe - 04-07-2010 03:25 PM --> http://www.isp-control.net/documentation/doku.php?id=howto:miscellaneous:run_ispcp_on_a_low_resources_system Greez BeNe RE: Reducing memory usage - pete - 04-08-2010 03:11 PM Thanks BeNe, I'll try that. RE: Reducing memory usage - dcreation - 04-08-2010 08:58 PM Your Apache dont use that much memory It uses "0,5% of total" which means around 3MB. RE: Reducing memory usage - kilburn - 04-08-2010 10:24 PM Tracking memory usage is not a simple task, and dcreation gave you an initial hint of it. First of all, assuming that you have no SWAP space, the virtual memory (VIRT) used by a process is completely irrelevant. Next, the most important figure is the physical memory being used (RES column), which says that your apache instances are consuming approximately 5mb each). Nevertheless, this is not entirely true, as part of this memory is shared with other processes (those that use the same libraries). A hint about the amount of memory that *might* be shared with other processes is shown in the SHR column. For your apache case, this column shows that approx. 1.3mb of each apache process are potentially being shared (not just among the apache process, but with any other program using the same libs). Finally, adding the RES value of all your processes gives you a *worst case* (this is, considering that no memory is shared between processes at all which is NOT the case) of 180mb being used by your system. RE: Reducing memory usage - pete - 04-09-2010 07:29 PM BeNe, your suggestion worked a treat, thanks. dcreation, in theory you're right but in my case the VPS I'm using doesn't have swap space so all virtual memory equals virtual machine memory. My limit is 1GB and my server is often dangerously close to that mark. Not surprisingly, at times things stop working due to memory allocation errors. With BeNe's help, I now reduce overall memory down to about 400mb. (04-08-2010 10:24 PM)kilburn Wrote: First of all, assuming that you have no SWAP space, the virtual memory (VIRT) used by a process is completely irrelevant. Just when I thought I could understand this stuff someone throws a spanner in the works. What is virtual memory then? I mean, in C (and implicitly C++) we use malloc and free to manage the applications heap storage. Apart from the heap, there is stack space, code of the module itself and shared libraries, but combined, these would be a small fraction of the 144mb stated. So I assume that a large portion of the 144mb has been allocated via [many calls to] malloc. In the absence of a swap device, where exactly would the OS put allocated memory? I can only assume that the "no" in your comment is a typo. If I don't have a SWAP device, then surely virtual memory=physical memory (with the exceptions of shared code you mentioned), right? If not, what is "virtual memory" in top's vocabulary? RE: Reducing memory usage - kilburn - 04-10-2010 03:27 AM See this thread for further insight |