Quote:
Originally Posted by
jlliagre
You still don't give a clue about the allocated area sizes
Ok, more accurately but still quite roughly:
at the starting of the C++ program the OS is using ~0.3GB or ram. The program stores ~3000 text files of unknown size in ram, one by one, via realloc(). All the files should fit into less than 2GB and, anyway, when realloc() fails there are still ~0.8GB available (40% of 2GB). At that time realloc() has allocated 2-0.3-0.8 ~=0.9GB.
Each file is stored independently: realloc() makes space for one single file at each time. The space is allocated in increment of 500KB. It means that if a file is 800KB, realloc() works twice and allocates 1MB.
It happens that when the allocated memory reaches ~1.2GB (OS=0.3, program=0.9), realloc() returns NULL when attempting to allocated another 500KB.
As long as realloc() does not allocated more than those ~0.9GB, everything works just fine.
Thanks again.