PDA

View Full Version : Memory Error



spongebob
7th May 2010, 12:06
Hello All,
I was wondering what kind of wrong coding could run that kind of error :

It happens when I quit my program :

======= Memory map: ========
08048000-080e8000 r-xp 00000000 08:08 240106 /home/anthony/Bureau/DOUCHE/TALC/Talc
080e8000-080e9000 r--p 000a0000 08:08 240106 /home/anthony/Bureau/DOUCHE/TALC/Talc
080e9000-080ea000 rw-p 000a1000 08:08 240106 /home/anthony/Bureau/DOUCHE/TALC/Talc
080ea000-080eb000 rw-p 080ea000 00:00 0
0925c000-0a3a9000 rw-p 0925c000 00:00 0 [heap]
af700000-af721000 rw-p af700000 00:00 0
af721000-af800000 ---p af721000 00:00 0
af852000-b0263000 r--p 00000000 08:08 442431 /usr/share/fonts/truetype/sazanami/sazanami-mincho.ttf
b0263000-b0269000 r--p 00000000 08:08 807923 /usr/share/fonts/truetype/latex-xft-fonts/cmsy10.ttf
b0269000-b02db000 r--p 00000000 08:08 385554 /usr/share/fonts/truetype/freefont/FreeSans.ttf
b02db000-b0301000 r--p 00000000 08:08 856396 /usr/share/fonts/truetype/ttf-telugu-fonts/lohit_te.ttf
b0301000-b032f000 r--p 00000000 08:08 856378 /usr/share/fonts/truetype/ttf-kannada-fonts/lohit_kn.ttf
b032f000-b0342000 r--p 00000000 08:08 420848 /usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_hi.ttf
b0342000-b0356000 r--p 00000000 08:08 420849 /usr/share/fonts/truetype/ttf-indic-fonts-core/lohit_gu.ttf
b0356000-b0378000 r--p 00000000 08:08 856362 /usr/share/fonts/truetype/ttf-bengali-fonts/lohit_bn.ttf
b0378000-b0594000 r--p 00000000 08:08 680121 /usr/share/fonts/truetype/unfonts/UnDotum.ttf
b0594000-b0cea000 r--p 00000000 08:08 442424 /usr/share/fonts/truetype/sazanami/sazanami-gothic.ttf
b0cea000-b0d18000 r--p 00000000 08:08 420846 /usr/share/fonts/truetype/ttf-indic-fonts-core/MuktiNarrow.ttf
b0d18000-b212d000 r--p 00000000 08:08 442400 /usr/share/fonts/truetype/arphic/uming.ttc
b212d000-b218d000 rw-s 00000000 00:09 1343501 /SYSV00000000 (deleted)
b218d000-b218f000 rwxp 00000000 00:0f 766 /dev/zero
b218f000-b35a4000 r--p 00000000 08:08 442400 /usr/share/fonts/truetype/arphic/uming.ttc
b35a4000-b35b8000 r--p 00000000 08:08 418755 /usr/share/fonts/type1/gsfonts/n019003l.pfb
b35b8000-b3644000 r--p 00000000 08:08 680038 /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Bold.ttf
b3644000-b3695000 r--p 00000000 08:08 685067 /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-ExtraLight.ttf
b3695000-b36d8000 rw-p 00000000 00:0f 766 /dev/zero
b36d8000-b36f9000 r--p 00000000 08:08 550533 /usr/share/fonts/truetype/ttf-liberation/LiberationSans-Regular.ttf
b36f9000-b374b000 r-xp 00000000 08:08 331549 /usr/lib/libtiff.so.4.2.1
b374b000-b374c000 ---p 00052000 08:08 331549 /usr/lib/libtiff.so.4.2.1
b374c000-b374e000 r--p 00052000 08:08 331549 /usr/lib/libtiff.so.4.2.1
b374e000-b374f000 rw-p 00054000 08:08 331549 /usr/lib/libtiff.so.4.2.1
b374f000-b37a1000 r-xp 00000000 08:08 319910 /usr/lib/libQtSvg.so.4.5.0
b37a1000-b37a2000 ---p 00052000 08:08 319910 /usr/lib/libQtSvg.so.4.5.0
b37a2000-b37a3000 r--p 00052000 08:08 319910 /usr/lib/libQtSvg.so.4.5.0
b37a3000-b37a4000 rw-p 00053000 08:08 319910 /usr/lib/libQtSvg.so.4.5.0
b37a8000-b37bf000 r--p 00000000 08:08 856384 /usr/share/fonts/truetype/ttf-oriya-fonts/lohit_or.ttf
b37bf000-b37ef000 r-xp 00000000 08:08 334345 /usr/lib/liblcms.so.1.0.18
b37ef000-b37f0000 r--p 00030000 08:08 334345 /usr/lib/liblcms.so.1.0.18
b37f0000-b37f1000 rw-p 00031000 08:08 334345 /usr/lib/liblcms.so.1.0.18

Here is what i am doing :


TalkWindow::saveConf();

list<MotionStyle*>::iterator mScenesIt;
list<Source*>::iterator mSourcesIt;
list<Font*>::iterator mFontsIt;

//map<std::string, QTimer*>::iterator mTimersIt;

/*if (mDisplayStyle->isStarted())
mDisplayStyle->stop();*/
TalkWindow::on_stopButton_clicked();

delete mDisplayStyle;

for (mSourcesIt = mSources.begin(); mSourcesIt != mSources.end(); mSourcesIt++)
{
delete *mSourcesIt;
mSourcesIt = mSources.erase(mSourcesIt);
}

for (mScenesIt = mScenes.begin(); mScenesIt != mScenes.end(); mScenesIt++)
{
delete *mScenesIt;
mScenesIt = mScenes.erase(mScenesIt);
}

/*for (mTimersIt = mTimers.begin(); mTimersIt != mTimers.end(); mTimersIt++)
delete mTimersIt->second;

mTimers.clear();*/

for (mFontsIt = mFonts.begin(); mFontsIt != mFonts.end(); mFontsIt++)
{
delete *mFontsIt;
mFontsIt = mFonts.erase(mFontsIt);
}

if(mCheckInfosTimer)
mCheckInfosTimer->stop();
// delete mCheckInfosTimer;

mPomme->destroy();
delete mPomme;
}


Thank you for everything.

^NyAw^
7th May 2010, 12:38
Hi,

First of all, use a debugger to debug your application. Step by step will help you to find the error code line as it is a runtime error.
Second, it seems that you delete something in the memory and then you tell "mSources" to erase it. Since the memory object has been destroyed it can't be erased and so it crashes.

borisbn
7th May 2010, 13:27
you shouldn't do mSourcesIt++, mScenes++ and mFonts++ because erase (http://cplusplus.com/reference/stl/vector/erase/)


Return value
A random access iterator pointing to the new location of the element that followed the last element erased by the function call, which is the vector end if the operation erased the last element in the sequence.