question for malloc & free.

F

Franklin

Hi All,

If I use malloc to get some memory, and don't use free to release them, OS
will release them for me when the application ends.

If OS can release them, it means that Memory Leak only in the living of the
APP?

Does it exit the situation that OS doesn't release the memory for APP when
it ends?

PS: which books could I refer?

Thank you so much!

Franklin
 
A

Artie Gold

Franklin said:
Hi All,

If I use malloc to get some memory, and don't use free to release them, OS
will release them for me when the application ends.

Probably. But that's up to the OS -- and is therefore outside of the
purview of the C language itself.
If OS can release them, it means that Memory Leak only in the living of the
APP?

In that case, yes.

Memory leaks, while always a concern, are typically of greatest concern
in the case of a `long-running' application (one that's intended to
remain running for hours, days weeks -- or even years -- at a time).

But a memory leak is *always* a Bad Thing; after all if one exists in a
program, what other kinds of ugly things may be lurking in the code.
Does it exit the situation that OS doesn't release the memory for APP when
it ends?
Again, that's outside of the realm of the language.

HTH,
--ag
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top