for(int i = 0 ; i < numOfTraces ; i++){ TraceClass *trace = new TraceClass(); qDebug() << trace; printf("ii=%d,size =%d\n",i,sizeof(TraceClass)); trace->readTraceHead(fmp); delete trace; trace = NULL; fmp += 240 + 4L * samples; progress->setValue(i+1); qApp->processEvents(QEventLoop::ExcludeUserInputEvents); if(progress->wasCanceled()){ inLineHashMap.clear(); xLineHashMap.clear(); return false; } }voidTraceClass::readTraceHead(uchar*fmp){char*s;longtemplong;shorttempshort;memcpy(&templong,fmp,4);fmp+=4;s=(char*)&templong;TraceHead.TRACENUMBERLINE=BinToLong(s);//001-004
}(1)如果把fmp +=240 + 4L * samples;注釋掉,運行程序,內(nèi)存不會變化很大;(2)如果把memcpy這句話注釋掉,內(nèi)存不會飆升,如果不注釋掉,內(nèi)存上升很快達到G。 請了解的大神指教
C++中重復調(diào)用memcpy函數(shù),會導致內(nèi)存不斷增加是怎么回事?
ibeautiful
2018-11-07 10:14:39