This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Realloc returns NULL
- From: "Jeff Baumes" <jeff dot baumes at kitware dot com>
- To: libc-help at sourceware dot org
- Date: Thu, 18 Dec 2008 17:11:15 -0500
- Subject: Realloc returns NULL
Is there any reason that realloc() could return NULL without running
out of memory on the system? My system memory is at 0.5GB out of 4GB
when it crashes, so it doesn't appear to be an out-of-memory error.
The requested realloc call is for 320K on a pointer that currently is
allocated for 160K. I am running a multi-threaded application, where
the failure occurs in a "worker" thread (not the main thread).
Valgrind does not come up with any memory errors. If I replace the
realloc with a malloc, memcpy, and free, the error does not appear. I
am using libc version 2.7 on Ubuntu, gcc version 4.2.4.
Thanks,
Jeff