On 02/10/12 13:55, jody wrote:
> I also don't understand why the Cell is deleted twice, because
> destroyGrid() does this in a loop (see below),
> and all other destructors are called only once.
>
> ---------------------------------
> void CellGrid::destroyGrid() {
>
> if (m_apCells != NULL) {
> for (coord j = 0; j < m_iNumCells; j++) {
> if (m_apCells[j] != NULL) {
> delete m_apCells[j];
> }
> }
> delete[] m_apCells;
> }
>
> //.... other stuff unrelated to m_apCells
> }
Although you check for m_apCells being null before doing the cleanup
here you don't actually set it to null after the delete, so if this
routine is called a second time it will try and cleanup an array that
has already been freed.
> ---------------------------------
> Since this error does not appear for smaller array sizes, i suspect there
> must be some overwriting, but valgrind does not report this...
Are smaller arrays perhaps handled by a fixed size array of cells that
is part of the objects, with dynamic allocation of an auxiliary cell
array only being used when the cell count gets too large?
Tom
--
Tom Hughes ([email protected])
http://compton.nu/
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users