memory leak?

Started by
3 comments, last by rip-off 12 years, 6 months ago
in C/C++ are memory leaks clean up at exit/completion of a program?
Advertisement
On modern PC platforms, yes. Other platforms may or may not.
To clarify further:

It depends. There may be OS resources which are NOT automatically reclaimed. Local OS resource will usually be cleaned up.

Any local resources (newed, malloced, etc.) are cleaned up.


However, it is not good practise to rely on that.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

For any resources that aren't picked up by the garbage collector (C#, for example, has an automatic garbage collector) there are manual ways to delete it from the memory. Not sure if this is different between gpu and cpu though.
Morley

Aspiring programmer, modeler and game designer.
One problem related to memory leaks are other resource leaks. There are lots of things that the OS cannot do for you. For example, if you have unflushed data in an application buffer, the OS doesn't know about that. The file handle will be closed, but this data will be lost.

Worse than lost data, it can cause your file loading to fail, which means that not only is this additional data lost, the rest of the successfully written data is effectively corrupt.

This aside, if your program intends to run for a long time, you should ensure you have no memory leaks. They will slow down your program, and could eventually crash it. You should assume your program will be running a long time - the user might need or want leave it running for some reason and they would be very annoyed if it were to crash or become unusable if this happens.

This topic is closed to new replies.

Advertisement