{"action":"created","issue":{"url":"https://api.github.com/repos/robotology/QA/issues/122","repository_url":"https://api.github.com/repos/robotology/QA","labels_url":"https://api.github.com/repos/robotology/QA/issues/122/labels{/name}","comments_url":"https://api.github.com/repos/robotology/QA/issues/122/comments","events_url":"https://api.github.com/repos/robotology/QA/issues/122/events","html_url":"https://github.com/robotology/QA/issues/122","id":162098084,"number":122,"title":"IplImage* has memory leak, how to release memory ?","user":{"login":"pattacini","id":3738070,"avatar_url":"https://avatars.githubusercontent.com/u/3738070?v=3","gravatar_id":"","url":"https://api.github.com/users/pattacini","html_url":"https://github.com/pattacini","followers_url":"https://api.github.com/users/pattacini/followers","following_url":"https://api.github.com/users/pattacini/following{/other_user}","gists_url":"https://api.github.com/users/pattacini/gists{/gist_id}","starred_url":"https://api.github.com/users/pattacini/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pattacini/subscriptions","organizations_url":"https://api.github.com/users/pattacini/orgs","repos_url":"https://api.github.com/users/pattacini/repos","events_url":"https://api.github.com/users/pattacini/events{/privacy}","received_events_url":"https://api.github.com/users/pattacini/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/robotology/QA/labels/discussion","name":"discussion","color":"bfd4f2"},{"url":"https://api.github.com/repos/robotology/QA/labels/software","name":"software","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-06-24T08:17:16Z","updated_at":"2016-06-29T09:43:32Z","closed_at":null,"body":"@Tariq-Abuhashim commented on [Fri Jun 24 2016](https://github.com/robotology/stereo-vision/issues/12)\n\nIplImage* cvImageL  allocates the memory, and cvReleaseImage( &cvImageL ) is supposed to release it. Looks like it only deletes the pointer, but not the physical memory allocated.\r\nThis seems to be caused by cvLoadImage:\r\nIplImage* cvImageL = cvLoadImage( left_img_file_name.c_str() );\r\n\r\n==8172== LEAK SUMMARY:\r\n==8172==    definitely lost: 0 bytes in 0 blocks\r\n==8172==    indirectly lost: 0 bytes in 0 blocks\r\n==8172==      possibly lost: 0 bytes in 0 blocks\r\n==8172==    still reachable: 88 bytes in 3 blocks\r\n==8172==         suppressed: 0 bytes in 0 blocks\r\n==8172== Rerun with --leak-check=full to see details of leaked memory\r\n\r\nAny ideas on how to empty the allocated memory ?\r\n\n\n---\n\n@pattacini commented on [Fri Jun 24 2016](https://github.com/robotology/stereo-vision/issues/12#issuecomment-228285172)\n\nIt seems unrelated to `stereo-vision`, although `stereo-vision` still makes use of old OpenCV code.\r\nMoving to Q&A...\n\n"},"comment":{"url":"https://api.github.com/repos/robotology/QA/issues/comments/229308849","html_url":"https://github.com/robotology/QA/issues/122#issuecomment-229308849","issue_url":"https://api.github.com/repos/robotology/QA/issues/122","id":229308849,"user":{"login":"lornat75","id":1403333,"avatar_url":"https://avatars.githubusercontent.com/u/1403333?v=3","gravatar_id":"","url":"https://api.github.com/users/lornat75","html_url":"https://github.com/lornat75","followers_url":"https://api.github.com/users/lornat75/followers","following_url":"https://api.github.com/users/lornat75/following{/other_user}","gists_url":"https://api.github.com/users/lornat75/gists{/gist_id}","starred_url":"https://api.github.com/users/lornat75/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lornat75/subscriptions","organizations_url":"https://api.github.com/users/lornat75/orgs","repos_url":"https://api.github.com/users/lornat75/repos","events_url":"https://api.github.com/users/lornat75/events{/privacy}","received_events_url":"https://api.github.com/users/lornat75/received_events","type":"User","site_admin":false},"created_at":"2016-06-29T09:43:32Z","updated_at":"2016-06-29T09:43:32Z","body":"it seems strange that `cvReleaseImage()` does not free all the previously allocated memory (e.g. by `cvLoadImage( )`. This would imply a huge memory leak in opencv.\r\n\r\nBTW: the way I have found most convenient to pass a YARP Image to OpenCV is by creating a Mat object and initialize it from a IplImage pointer, i.e.:\r\n\r\n```\r\nImageOf<PixelRgb> image;\r\n/* fill image content */\r\nMat image_cv((IplImage *)image.getIplImage());\r\n/* now image_cv can be used in opencv*/\r\n```\r\n\r\nIn my understanding this is quite efficient because `image_cv` shares storage allocated by `image`. Memory is therefore managed by YARP.\r\n\r\nYou just have to be careful that `image_cv` and `image` share their content.\r\n\r\nis there a better method? @vtikha\r\n\r\n\r\n"}}
{"actor":{"display_login":"lornat75"}}