This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: garbage collector never runs!!
- To: gcc at gcc dot gnu dot org, rob at e-critical dot com
- Subject: Re: garbage collector never runs!!
- From: Mike Stump <mrs at windriver dot com>
- Date: Fri, 8 Dec 2000 08:49:51 -0800 (PST)
> Date: Fri, 08 Dec 2000 01:52:07 -0800
> From: Rob Willis <rob@e-critical.com>
> To: gcc@gcc.gnu.org
> I've been having some strange "memory leaks" in my code. So i spent
> a lot of time trying to track down the problem only to discover my
> "leak" seems to caused by the default behaviour of the gc.
It isn't really gc. Also, this has nothing to do with the compiler,
making this the wrong list.
Welcome to UNIX, welcome to C, welcome to malloc.
If you want to learn more about this, you you may want to study
malloc, brk, sbrk and mmap behaviors. There is far too much detail
here for me to do a good job of it. Simply put, it is most optimal to
do what is done. One can get the specific memory performance you
want, if you are willing to sacrifice performance? If you want to do
that, call mmap yourself, once per allocation. Most people, in most
situations do not want to do this, which is why malloc does what it
does.
At this point, I would recommend checking out the malloc source code
from glibc, and studying it. There might be a book or some papers
about this sort of stuff, but I don't happen to have a reference.