Browse Source

added several comments with Valgrind information on memory leaks

pull/7/head
Stéphane Charette 10 months ago
parent
commit
370c798689
  1. 16
      lib/App/common/SQLite_dataBinder.cpp
  2. 35
      lib/App/common/hardwareManager.cpp
  3. 21
      lib/App/common/kernelModuleEmbedVideo.cpp
  4. 18
      lib/alg/generic/md5.cpp
  5. 15
      lib/components/base/basicPosition.cpp
  6. 32
      lib/data/media/video/videoAVLIBSource.cpp

16
lib/App/common/SQLite_dataBinder.cpp

@ -2950,6 +2950,22 @@ uint32_t sqliteDBC::getResourceID( uint32_t NodeID, uint8_t type, uint32_t auxID
return RetVal; return RetVal;
}; };
DBC_SITE_DATA *sqliteDBC::getSiteData( uint32_t ID ){ DBC_SITE_DATA *sqliteDBC::getSiteData( uint32_t ID ){
/** @todo Valgrind is reporting an important memory leak in this method.
* See these details:
*
* ~~~~
==00:00:04:04.218 26021== 28,304 bytes in 122 blocks are definitely lost in loss record 3,966 of 3,972
==00:00:04:04.218 26021== at 0x483877F: malloc (vg_replace_malloc.c:307)
==00:00:04:04.218 26021== by 0x23452A: sqliteDBC::getSiteData(unsigned int) (SQLite_dataBinder.cpp:2981)
==00:00:04:04.218 26021== by 0x1DA681: mojoKernel::validateReports() (mojoKernel.cpp:1347)
==00:00:04:04.218 26021== by 0x1D7D16: mojoKernel::m_fThreadProc() (mojoKernel.cpp:511)
==00:00:04:04.218 26021== by 0x131B54: basicThread::m_fThreadEntryPoint(void*) (basicThread.cpp:62)
==00:00:04:04.218 26021== by 0x49B7EA6: start_thread (pthread_create.c:477)
==00:00:04:04.218 26021== by 0x7874ADE: clone (clone.S:95)
* ~~~~
*/
DBC_SITE_DATA * tVal = NULL; DBC_SITE_DATA * tVal = NULL;
if( m_bStoIsConnected ){ if( m_bStoIsConnected ){
char tQBuf[CTEXT]; char tQBuf[CTEXT];

35
lib/App/common/hardwareManager.cpp

@ -215,6 +215,41 @@ void hardwareManager::unloadResources( void ){
}; };
void hardwareManager::loadResources( void ){ void hardwareManager::loadResources( void ){
/** @todo Valgrind is showing several memory leaks from this function.
*
* ~~~~
==00:00:04:04.207 26021== 513 (480 direct, 33 indirect) bytes in 1 blocks are definitely lost in loss record 3,863 of 3,972
==00:00:04:04.207 26021== at 0x4838DEF: operator new(unsigned long) (vg_replace_malloc.c:342)
==00:00:04:04.207 26021== by 0x16D0EF: hardwareManager::loadResources() (hardwareManager.cpp:318)
==00:00:04:04.207 26021== by 0x16C9CE: hardwareManager::hardwareManager(bool) (hardwareManager.cpp:174)
==00:00:04:04.207 26021== by 0x16C470: hardwareManager::getInstance(bool) (hardwareManager.cpp:55)
==00:00:04:04.207 26021== by 0x1D6E89: mojoKernel::create() (mojoKernel.cpp:264)
==00:00:04:04.207 26021== by 0x1D5C60: main (mojoBackend.cpp:476)
==00:00:04:04.207 26021== by 0x779CD79: __libc_start_main (libc-start.c:308)
==00:00:04:04.207 26021== by 0x124CF9: _start (in /home/stephane/src/argus/Projects/la_mojo/Debug86/mojo_d)
==00:00:04:04.207 26021== by 0x1FFF000497: ???
==00:00:04:04.207 26021== by 0x1B: ???
* ~~~~
*
* And:
*
* ~~~~
==00:00:04:04.198 26021== 240 bytes in 3 blocks are definitely lost in loss record 3,796 of 3,972
==00:00:04:04.198 26021== at 0x483877F: malloc (vg_replace_malloc.c:307)
==00:00:04:04.198 26021== by 0x233EAA: sqliteDBC::getResourceData(unsigned int) (SQLite_dataBinder.cpp:2897)
==00:00:04:04.198 26021== by 0x16CD43: hardwareManager::loadResources() (hardwareManager.cpp:260)
==00:00:04:04.198 26021== by 0x16C9CE: hardwareManager::hardwareManager(bool) (hardwareManager.cpp:174)
==00:00:04:04.198 26021== by 0x16C470: hardwareManager::getInstance(bool) (hardwareManager.cpp:55)
==00:00:04:04.198 26021== by 0x1D6E89: mojoKernel::create() (mojoKernel.cpp:264)
==00:00:04:04.198 26021== by 0x1D5C60: main (mojoBackend.cpp:476)
==00:00:04:04.198 26021== by 0x779CD79: __libc_start_main (libc-start.c:308)
==00:00:04:04.198 26021== by 0x124CF9: _start (in /home/stephane/src/argus/Projects/la_mojo/Debug86/mojo_d)
==00:00:04:04.198 26021== by 0x1FFF000497: ???
==00:00:04:04.198 26021== by 0x1B: ???
* ~~~~
*/
if( m_pDBC == NULL ) return; if( m_pDBC == NULL ) return;
DBC_INT_LIST *tVal; DBC_INT_LIST *tVal;
tVal = m_pDBC->listResources( );//load whole site resources tVal = m_pDBC->listResources( );//load whole site resources

21
lib/App/common/kernelModuleEmbedVideo.cpp

@ -1998,6 +1998,21 @@ bool streamHandler::pushFrame( AVFrame *Frame, void* src){
}; };
bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){ bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){
/** @todo Valgrind is reporting an important memory leak in this method. The @p malloc() call on line 2568 (and others, such as 2576).
* The details are as follows:
*
* ~~~~
= =00:00:04:04.219 26021== 8,805,208 (4,416 direct, 8,800,792 *indirect) bytes in 184 blocks are definitely lost in loss record 3,972 of 3,972
==00:00:04:04.219 26021== at 0x483877F: malloc (vg_replace_malloc.c:307)
==00:00:04:04.219 26021== by 0x1B0FF9: streamHandler::pushFrame(cv::Mat&, void*) (kernelModuleEmbedVideo.cpp:2568)
==00:00:04:04.219 26021== by 0x2490CB: videoAVLIBSource::m_fThreadProc() (videoAVLIBSource.cpp:874)
==00:00:04:04.219 26021== by 0x131B54: basicThread::m_fThreadEntryPoint(void*) (basicThread.cpp:62)
==00:00:04:04.219 26021== by 0x49B7EA6: start_thread (pthread_create.c:477)
==00:00:04:04.219 26021== by 0x7874ADE: clone (clone.S:95)
* ~~~~
*/
bool SkeepW, SkeepA, SkeepB; bool SkeepW, SkeepA, SkeepB;
if( m_pMaster == NULL ) return false; if( m_pMaster == NULL ) return false;
MEDIA_SOURCE_DESC * tMD = (MEDIA_SOURCE_DESC *) src; MEDIA_SOURCE_DESC * tMD = (MEDIA_SOURCE_DESC *) src;
@ -3250,7 +3265,7 @@ bool streamHandler::initVideoOutput(){
m_pCodecACtx->max_b_frames = 5; m_pCodecACtx->max_b_frames = 5;
/// Can be used by a P-frame(predictive, partial frame) to help define a future frame in a compressed video. /// Can be used by a P-frame(predictive, partial frame) to help define a future frame in a compressed video.
/// [use 3–5 ref per P]
/// [use 3„1¤75 ref per P]
m_pCodecACtx->refs = 3; m_pCodecACtx->refs = 3;
/// Compression efficiency (slower -> better quality + higher cpu%) /// Compression efficiency (slower -> better quality + higher cpu%)
@ -3330,7 +3345,7 @@ bool streamHandler::initVideoOutput(){
m_pCodecBCtx->max_b_frames = 5; m_pCodecBCtx->max_b_frames = 5;
/// Can be used by a P-frame(predictive, partial frame) to help define a future frame in a compressed video. /// Can be used by a P-frame(predictive, partial frame) to help define a future frame in a compressed video.
/// [use 3–5 ref per P]
/// [use 3„1¤75 ref per P]
m_pCodecBCtx->refs = 3; m_pCodecBCtx->refs = 3;
/// Compression efficiency (slower -> better quality + higher cpu%) /// Compression efficiency (slower -> better quality + higher cpu%)
@ -3611,7 +3626,7 @@ bool streamHandler::initVideoOutput(){
m_pCodecCtx->max_b_frames = 5; m_pCodecCtx->max_b_frames = 5;
/// Can be used by a P-frame(predictive, partial frame) to help define a future frame in a compressed video. /// Can be used by a P-frame(predictive, partial frame) to help define a future frame in a compressed video.
/// [use 3–5 ref per P]
/// [use 3„1¤75 ref per P]
m_pCodecCtx->refs = 3; m_pCodecCtx->refs = 3;
/// Compression efficiency (slower -> better quality + higher cpu%) /// Compression efficiency (slower -> better quality + higher cpu%)

18
lib/alg/generic/md5.cpp

@ -81,6 +81,24 @@ char* PrintMD5(u_char md5Digest[16])
strncat(chBuffer, chEach, sizeof(chEach)); strncat(chBuffer, chEach, sizeof(chEach));
}; };
#ifdef __linux__ #ifdef __linux__
/** @todo Valgrind tells us this @p strdup() called from @ref videoAVLIBSource is never freed.
*
* ~~~~
= =00:00:04:04.006 26021== 33 bytes in 1 blocks are definitely* lost in loss record 2,412 of 3,972
==00:00:04:04.006 26021== at 0x483877F: malloc (vg_replace_malloc.c:307)
==00:00:04:04.006 26021== by 0x7802C3A: strdup (strdup.c:42) [now line 102 since I've inserted this comment]
==00:00:04:04.006 26021== by 0x1D20BD: PrintMD5(unsigned char*) (md5.cpp:84)
==00:00:04:04.006 26021== by 0x1D212A: MD5String(char*) (md5.cpp:100)
==00:00:04:04.006 26021== by 0x2476EA: videoAVLIBSource::_open(char*, bool, float, int, int, int, int, int) (videoAVLIBSource.cpp:388)
==00:00:04:04.006 26021== by 0x1AE949: streamHandler::create(dataBinder*, unsigned int) (kernelModuleEmbedVideo.cpp:1949)
==00:00:04:04.006 26021== by 0x1ADA24: kernelModuleEmbedVideo::registerStream(unsigned int, unsigned char) (kernelModuleEmbedVideo.cpp:1731)
==00:00:04:04.006 26021== by 0x1AC2A9: kernelModuleEmbedVideo::validate() (kernelModuleEmbedVideo.cpp:1347)
==00:00:04:04.006 26021== by 0x1BB1E7: kernelModuleFactory::m_fThreadProc() (kernelModuleFactory.cpp:397)
==00:00:04:04.006 26021== by 0x131B54: basicThread::m_fThreadEntryPoint(void*) (basicThread.cpp:62)
==00:00:04:04.006 26021== by 0x49B7EA6: start_thread (pthread_create.c:477)
==00:00:04:04.006 26021== by 0x7874ADE: clone (clone.S:95)
* ~~~~
*/
return strdup(chBuffer); return strdup(chBuffer);
#else #else
return _strdup(chBuffer); return _strdup(chBuffer);

15
lib/components/base/basicPosition.cpp

@ -205,6 +205,21 @@ void basicPosition::setPositionDeg(float Lat, float Lon, float Alt, float h_lat,
updateMatrix(); updateMatrix();
}; };
void basicPosition::updateMatrix( void ){ void basicPosition::updateMatrix( void ){
/** @todo Valgrind is showing several memory leaks from this function.
*
* ~~~~
==00:00:04:04.173 26021== 176 bytes in 2 blocks are definitely lost in loss record 3,541 of 3,972
==00:00:04:04.173 26021== at 0x4838DEF: operator new(unsigned long) (vg_replace_malloc.c:342)
==00:00:04:04.173 26021== by 0x130F5C: basicPosition::updateMatrix() (basicPosition.cpp:232)
==00:00:04:04.173 26021== by 0x167C58: deviceNodeSensor::reloadDeviceNodeFromDB() (deviceNodeSensor.cpp:298)
==00:00:04:04.173 26021== by 0x169DE2: deviceNodeSensor::m_fThreadProc() (deviceNodeSensor.cpp:1075)
==00:00:04:04.173 26021== by 0x131B54: basicThread::m_fThreadEntryPoint(void*) (basicThread.cpp:62)
==00:00:04:04.173 26021== by 0x49B7EA6: start_thread (pthread_create.c:477)
==00:00:04:04.173 26021== by 0x7874ADE: clone (clone.S:95)
* ~~~~
*/
//Tait-Bryan angles //Tait-Bryan angles
//X1Y2Z3 //X1Y2Z3
// C2C3 -C2S3 S2 // C2C3 -C2S3 S2

32
lib/data/media/video/videoAVLIBSource.cpp

@ -755,6 +755,38 @@ void videoAVLIBSource::m_fThreadProc( void ){
int dec_ret; int dec_ret;
char tB[256]; char tB[256];
/** @todo Valgrind is reporting several important memory leaks in this method.
*
* The first one has to do with @p av_frame_alloc():
*
* ~~~~
==00:00:04:04.219 26021== 2,074,168 (536 direct, 2,073,632 indirect) bytes in 1 blocks are definitely lost in loss record 3,970 of 3,972
==00:00:04:04.219 26021== at 0x483AEB8: memalign (vg_replace_malloc.c:906)
==00:00:04:04.219 26021== by 0x483AFCE: posix_memalign (vg_replace_malloc.c:1070)
==00:00:04:04.219 26021== by 0x66E2244: av_malloc (in /usr/lib/x86_64-linux-gnu/libavutil.so.56.70.100)
==00:00:04:04.219 26021== by 0x66E25FD: av_mallocz (in /usr/lib/x86_64-linux-gnu/libavutil.so.56.70.100)
==00:00:04:04.219 26021== by 0x66BF6BF: av_frame_alloc (in /usr/lib/x86_64-linux-gnu/libavutil.so.56.70.100)
==00:00:04:04.219 26021== by 0x248B0E: videoAVLIBSource::m_fThreadProc() (videoAVLIBSource.cpp:802)
==00:00:04:04.219 26021== by 0x131B54: basicThread::m_fThreadEntryPoint(void*) (basicThread.cpp:62)
==00:00:04:04.219 26021== by 0x49B7EA6: start_thread (pthread_create.c:477)
==00:00:04:04.219 26021== by 0x7874ADE: clone (clone.S:95)
* ~~~~
*
* The next one has to do with @p av_image_alloc():
*
* ~~~~
==00:00:04:04.219 26021== 2,073,632 bytes in 1 blocks are indirectly lost in loss record 3,969 of 3,972
==00:00:04:04.219 26021== at 0x483AEB8: memalign (vg_replace_malloc.c:906)
==00:00:04:04.219 26021== by 0x483AFCE: posix_memalign (vg_replace_malloc.c:1070)
==00:00:04:04.219 26021== by 0x66E2244: av_malloc (in /usr/lib/x86_64-linux-gnu/libavutil.so.56.70.100)
==00:00:04:04.219 26021== by 0x66DCEB5: av_image_alloc (in /usr/lib/x86_64-linux-gnu/libavutil.so.56.70.100)
==00:00:04:04.219 26021== by 0x248BCB: videoAVLIBSource::m_fThreadProc() (videoAVLIBSource.cpp:807)
==00:00:04:04.219 26021== by 0x131B54: basicThread::m_fThreadEntryPoint(void*) (basicThread.cpp:62)
==00:00:04:04.219 26021== by 0x49B7EA6: start_thread (pthread_create.c:477)
==00:00:04:04.219 26021== by 0x7874ADE: clone (clone.S:95)
* ~~~~
*/
m_bThreadStatus = TH_WORKING; m_bThreadStatus = TH_WORKING;
pPacket = (AVPacket *) av_malloc( sizeof(AVPacket) ); pPacket = (AVPacket *) av_malloc( sizeof(AVPacket) );
if ( pPacket == NULL ) { if ( pPacket == NULL ) {

Loading…
Cancel
Save