|
From: Patrick A. <al...@co...> - 2011-06-24 16:02:48
|
On 06/24/2011 04:25 PM, John Reiser wrote:
>> When the program runs by itself, all the malloc calls are successful.
>> However when I run it with valgrind's memcheck or massif tools (v
>> 3.6.0), a malloc call fails (which is trying to allocate around 6.4 Gb).
> Which Linux distribution, which Linux kernel ("uname -a"), and which
> C runtime library ("ls -l /lib*/libc.so*") are you running?
> There are various policies (such as automatic huge pages in some kernels)
> and various algorithms (such as malloc implementations in glibc)
> which might matter.
>
Ubuntu Lucid:
Linux maya 2.6.32-31-generic #61-Ubuntu SMP Fri Apr 8 18:25:51 UTC 2011
x86_64 GNU/Linux
libc:
lrwxrwxrwx 1 root root 14 2011-02-24 18:32 /lib/libc.so.6 -> libc-2.11.1.so
swapon -s:
Filename Type Size Used Priority
/dev/sda3 partition 95999992 0 -1
I tried a similar test case like yours and it works ok. Unfortunately my
program is extremely large and complicated. In fact I get other errors
like "conditional jump depends on uninitialized value" but these errors
exist in another part of the code entirely.
I modified the code to check after each malloc call. The valgrind output
looks like this now:
==15101== Warning: set address range perms: large range [0x5b806040,
0x35670e040) (undefined)
==15101== Warning: set address range perms: large range [0x40d709040,
0x708611040) (undefined)
nzval = 0x40d709040
pde_alloc: sparse matrix nzcol alloc failed: Success
==15101== Warning: set address range perms: large range [0x5b806030,
0x35670e050) (noaccess)
==15101== Warning: set address range perms: large range [0x40d709030,
0x708611050) (noaccess)
with code snippet:
w->nzval = malloc(PDE_MAT_SIZE1 * PDE_MAT_SIZE2 * sizeof(double));
if (!w->nzval)
{
fprintf(stderr, "pde_alloc: sparse matrix nzval alloc failed:
%s\n", strerror(errno));
pde_free(w);
return 0;
}
fprintf(stderr, "nzval = %p\n", w->nzval);
w->nzcol = malloc(PDE_MAT_SIZE1 * PDE_MAT_SIZE2 * sizeof(int));
if (!w->nzcol)
{
fprintf(stderr, "pde_alloc: sparse matrix nzcol alloc failed:
%s\n", strerror(errno));
pde_free(w);
return 0;
}
|