angeloseme / ofxLibsndfileRecorder

Audio recorder using sndfile libraries
13 stars 12 forks source link

memory leak + fix #2

Closed arneboon closed 12 years ago

arneboon commented 12 years ago

hi angelo,

thanks for developing this of library, it worked out of the box for me on osx 10.7.2 / xcode 4.1 / openframeworks 007 github develop branche 2012-04.

i tested the example in Apple Instruments for memory leaks and allocations and i detected a memory leak in ofxLibsndFileRecorder::setup(string fileName, int sampleRate, int numChannels) on outFile=new SndfileHandle(ofToDataPath(fileName,true),SFM_RDWR, audioFormat, numChannels, sampleRate);

outFile is never cleaned out before creating the new SndfileHandle in a new recording.

so i in ofxLibsndFileRecorder.cpp for void ofxLibsndFileRecorder::finalize(){ i added as last line within the if(initialized){ statement (line 59 in ofxLibsndfileRecorder.cpp)

delete outFile;

testing it again in instuments showed the memory leak was gone.

you might want to test it out for yourself and add this fix to the repository when affirmitive.

thanks for your attention reading this message.

best regards,

arne.

more: http://www.ehow.com/how_2190610_prevent-memory-leaks-c.html and: http://gigaom.com/apple/apples-instruments-for-developers/

angeloseme commented 12 years ago

Thanks Arne! You're right! I forgot deleting outFile. I'm updating it right now

arneboon commented 12 years ago

Great! Thanks, Arne.