![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem with memory leak | kshk123 | HP-UX | 2 | 05-25-2009 07:01 AM |
| memory leak problem | sonali | High Level Programming | 5 | 05-25-2009 06:55 AM |
| memory leak? | lenna | IP Networking | 2 | 05-25-2009 06:35 AM |
| Memory leak in pthread | mindTeaser | UNIX for Advanced & Expert Users | 4 | 05-18-2009 01:30 AM |
| cpu, memory and virtual memory usage | ocelot | UNIX for Dummies Questions & Answers | 4 | 12-01-2008 07:57 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
about virtual memory and memory leak
Hi,
First of all I appreciate this group very much for its informative discussions and posts. Here is my question. I have one process whose virtual memory size increases linearly from 6MB to 12MB in 20 minutes. Does that mean my process has memory leaks? In what cases does the memory leak?. I just have preliminary idea that if you donot free the memory which is not in use, u have memory leak in ur program. It would be really great if someone can post info about memory leak. Some link would do. Thanks in advance, -Ashish |
|
||||
|
Quote:
have signal handlers as guards in your program, whenever the program crashes due to illegal access somehow you need to free the memory acquired through malloc dangling pointers is one such case just assign NULL to freed members programs resisting to release the memory (heap) eventually increases the heap size |
|
||||
|
The system calls brk() or sbrk() on behalf of the process to get chunks of memory.
As the program runs and requests more memory, the system calls for more. Generally, this memory accumulates, with the idea that since the processes needed it before, it may well need it again. Calling brk() & sbrk() is expensive. The simple way to see a memory leak is have the code run for longer periods. If memory continually grows, then there is probably problem. If you need to find the leak - try either Electric Fence or Valgrind. They are available free, and have been ported to most versions of UNIX. |
|
||||
|
I have a C program that I suspect of memory leak.
However, the memory leak occurs when I kill -9 the program and restart the program to run as a daemon. I didn't see the memory leak problem when the daemon is not killed and restarted at least 5 times. The CPU usage on the server drop to ZERO everytime I kill the process BUT whenever I restart the process, it consume 2% more than it did the previous time. Is this possible? I dun understand why did the CPU util dropped to ZERO after I kill the porcess if it is a memory leak. |
|
||||
|
Why not create a SIGTERM signal handler that does a graceful exit? Graceful meaning you call an atexit() handler to clean up memory.
kill -9 is generally a bad idea. Even if you don't write an exit handler, do not use SIGKILL (kill -9) because it can prevent any further operations by the system on behalf of the process. The process leaves junk behind when this happens. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|