![]() |
|
|
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 |
| Memory usage in Solaris - memory not freed? | gewurtz | SUN Solaris | 3 | 01-06-2009 12:06 PM |
| malloc gives the same memory to two different nodes. How to deal with it? | cdbug | High Level Programming | 2 | 01-04-2009 09:01 PM |
| mv files still in use - space not freed | apra143 | Filesystems, Disks and Memory | 4 | 01-08-2008 07:47 PM |
| Memory allocated | baanprog | SUN Solaris | 1 | 05-04-2006 11:06 AM |
| malloc | rajashekaran | High Level Programming | 2 | 09-30-2002 06:24 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Why memory allocated through malloc should be freed ?
Actually for a process to run it needs text, stack , heap and data segments. All these find a place in the physical memory.
Out of these 4 only heap does exist after the termination of the process that created it. I want to know the exact reason why this happens. Also why the other process need to access the heap of my process. If the other processes compete for the heap that my process has consumed then there wont be need of an IPC mechanism (like my process will put the information in the heap and give that address to the peer process to have the info shared) ... My question is really simple, I am not freeing the text , data and stack segments used by my process, then y should i do it for heap alone? ![]() |
|
||||
|
I am using fedora 6
But y u say "All of a process allocated memory should be made available after it dies otherwise the OS will refuse to launch after some period of time" After a process dies y should its address space be avilable ? y OS wont launch when a process dies ? I dont understand the point u try to make.. |
|
||||
|
Please use English. It's quite boring for non native speaker (and probably for native ones) to decrypt non standard English.
Also, please answer the second question I asked. After a process dies, all of its address space should be made available otherwise that would be a memory leak. Memory leaks always end in some crash or denial of service which is particularly unwanted for an operating system. |
|
||||
|
Quote:
The point that lies here is - if each and every process that have got poor memory allocation and deallocation within it, will start creating memory leaks ( try hitting memory leak in any SEs - good links will be provided ), slowly it will be using all of the available memory depriving any new process to be booted or loaded due to insufficient memory. |
|
||||
|
I understand that, But any part of the process's address space being leaked leads to a memory leak. But stack, data and text segments' memory is not at all leaked. Beacuse they are freed by the OS itself when a process terminates. But Heap alone needs to be freed explicitly. why is that so?
I use the "size"" command to find the size of each segment. ---------- Post updated at 07:23 PM ---------- Previous update was at 07:20 PM ---------- I understand your point matrix madhan. But can you expalin why the stack or data or text segment's memory is not leaked at all? |
|
||||
|
Quote:
With more power comes more responsibility ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|