I have a program which does a bunch of mallocs and frees over a loop, some thing
similar to below:
for {
When I run a program with the latest valgrind, i get the following message, after it runs through few loops:
Invalid write of size 4
==25986==    at 0x8098FDE: xxxx (xxx.c:147)
==25986==    by 0x8049918: xxxxxx (xxx.c:136)
==25986==    by 0x804930D: xxx (xx.c:99)
==25986==  Address 0x74 is not stack'd, malloc'd or (recently) free'd
However when i run it with an older version of valgrind, i get the following message:
VG_(get_memory_from_mmap): request for 261509120 bytes failed.
VG_(get_memory_from_mmap): 1983773742 bytes already allocated.
This may mean that you have run out of swap space,
since running programs on valgrind increases their memory
usage at least 3 times.  You might want to use 'top'
to determine whether you really have run out of swap.
If so, you may be able to work around it by adding a
temporary swap file -- this is easier than finding a
new swap partition.  Go ask your sysadmin(s) [politely!]
VG_(get_memory_from_mmap): out of memory!  Fatal!  Bye!
which tells me that valgrind is not able to allocate the memory in the first place.
I am unable to understand this as the memory that i am allocating in each loop is
free in the same loop, yet valgrind is not able to recognize the freed memory and reuse it. Any suggestions as to how i can overcome this will be greatly appreciated as this is very critical for qualifying my code.
Thank you

Yahoo! for Good - Make a difference this year.