I am new to using Crouton. I am trying to use it for some C programming practice in a linux environment. Anytime I run a program that uses malloc(), I get a memory leak error for x amount of bytes. The memory leak error dissipates when I explicitly free the allocated memory. Is this a Crouton issue or a Ubuntu issue overall?
Is there any way to fix it so that I do not have to explicitly free allocated space every time? I understand the free()ing is good coding practice and whatnot, but I was just wondering if there was a way so that allocated memory is automatically free'd after exiting.
On Linux (and most modern multi-tasked OSes) when a process is exiting (or is terminated, e.g. by a signal) all its resources are released by the OS kernel, including its virtual address space.
So it is certainly possible to forget to
freeheap memory before exiting, and many (but not all) programs are doing so.If you are developing an application, you might still want to properly
freeevery dynamically allocated memory zone when exiting. This facilitates the use of memory leak detecting tools like valgrind (but take some development efforts, and even some run time).