Hi all, I've come across some weird memory loss:<br><br><div style="margin-left: 40px;"><i>uint *data = new uint[region->width*region->height];<br>int x = 0, y = 0;<br>dataset->GetRasterBand(band)->RasterIO(GF_Read, x, y, width, height, data, width, height, GDT_UInt32, 0, 0);<br>
delete [] data;<br></i></div><br>This
code is executed a few thousand times with different x and y. After
doing this, 1.5GB memory was still used by my app. I'm using Ubuntu, and
apparently the linux kerenl manages memory differently, by not always
returning all freed memory to the OS, but rather keeping it for future
use by the application.<br>This is not the case here, since when
allocating memory after the above action, the freed memory is not
reused. I've tried valgrind for proof, but it crashes, since I'm using
too much memory, and valgrind can't handle it. <br><br>When I change the above code to:<br><br><div style="margin-left: 40px;"><i>uint *data = new uint[region->width*region->height];<br>
int x = 0, y = 0;<br>//dataset->GetRasterBand(band)->RasterIO(GF_Read, x, y, width, height, data, width, height, GDT_UInt32, 0, 0);<br>
delete [] data;<br></i></div><br>so effectively removing the read-statement, all memory is freed and returned. If also tried CPLMalloc and CPLFree, <br><br>The only way to get the memory release, is to close the dataset after all the reads. Is this a bug, or was/is GDAL designed only to release the memory after the dataset was close?<br>
<br>Chris