mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

Detected memory leaks by ASAN

Open toshiks opened this issue 3 years ago • 10 comments

System information

  • Have I written custom code (as opposed to using a stock example script provided in MediaPipe): stock example
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04, Android 11, iOS 14.4): Linux Ubuntu 20.04
  • Programming Language and version ( e.g. C++, Python, Java): C++
  • MediaPipe version: latest

Describe the current behavior:

I've built hand tracking example with -fsanitize=address gcc option and a lot of leaks was detected. All of them connected with REGISTER_CALCULATOR macros.

I explored deeper to codebase and detected, that REGISTER_FACTORY_FUNCTION_QUALIFIED creates static pointer in global environment. Why?

Is it possible to change raw pointer to unique_ptr (aka smart pointer)? Or what are the reasons for using raw pointers here? I've already tried unique_ptr and all leaks went away.

Describe the expected behavior:

No leaks.

Other info / Complete Logs : Example of Log:

Direct leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x55a15ddb8528 in operator new(unsigned long)
    #1 0x7f5c287858b1 in _GLOBAL__sub_I_packet_inner_join_calculator.cc

toshiks avatar Mar 30 '22 16:03 toshiks

Hi @toshiks , Did you get a chance to check this issue https://github.com/google/mediapipe/issues/205

sureshdagooglecom avatar Mar 31 '22 03:03 sureshdagooglecom

Hi @sureshdagooglecom , I've read issue #205. In my side application works stable. I note there, my target environment is the Desktop, it isn't Android. But I thinks, raw pointers can be the leak memory. In many places static variables are created by new operator. But I can't find any place where variables can be destructed by delete operator.

toshiks avatar Mar 31 '22 07:03 toshiks

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

google-ml-butler[bot] avatar Apr 07 '22 07:04 google-ml-butler[bot]

Closing as stale. Please reopen if you'd like to work on this further.

google-ml-butler[bot] avatar Apr 14 '22 07:04 google-ml-butler[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Apr 14 '22 07:04 google-ml-butler[bot]

Closing as stale. Please reopen if you'd like to work on this further.

google-ml-butler[bot] avatar Apr 27 '22 10:04 google-ml-butler[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Apr 27 '22 10:04 google-ml-butler[bot]

Closing as stale. Please reopen if you'd like to work on this further.

google-ml-butler[bot] avatar May 27 '22 05:05 google-ml-butler[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar May 27 '22 05:05 google-ml-butler[bot]

new operator usage there (registration) should be for global constants which are initialized only once and kept for the whole duration of program running.

If you see some other examples, could you please share them?

gkarpiak avatar Sep 06 '22 19:09 gkarpiak

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

google-ml-butler[bot] avatar Jan 13 '23 07:01 google-ml-butler[bot]

Closing as stale. Please reopen if you'd like to work on this further.

google-ml-butler[bot] avatar Jan 20 '23 08:01 google-ml-butler[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Jan 20 '23 08:01 google-ml-butler[bot]