Skip to content
This repository was archived by the owner on Jan 1, 2024. It is now read-only.
This repository was archived by the owner on Jan 1, 2024. It is now read-only.

OpenCV 4.7.0 Memory Leak (DNN?) #1

@brunohpg

Description

@brunohpg

Hi,

I have an application basic use DNN and lot of memory leak using opencv 4.7.0.

Thank you for your fix. I had some improvements, however, there is still a lot of memory leaks.

I made a small script to correct the original source and would like to share:

export OPENCV_VERSION=4.7.0
sed -i "s/final long nativeObj;/long nativeObj;/g" opencv-${OPENCV_VERSION}/modules/java/generator/templates/java_class.prolog
sed -i "s/delete(nativeObj);/free(); } public void free() { if (nativeObj != 0) { delete(nativeObj); nativeObj = 0; }/g" opencv-${OPENCV_VERSION}/modules/java/generator/gen_java.py

sed -i "s/n_delete(nativeObj);/free();/g" opencv-${OPENCV_VERSION}/modules/core/misc/java/src/java/core+Mat.java
sed -i "s/final long nativeObj;/long nativeObj; public void free() { if (nativeObj != 0) { release(); n_delete(nativeObj); nativeObj = 0; }}/g" opencv-${OPENCV_VERSION}/modules/core/misc/java/src/java/core+Mat.java
sed -i "s/%s_mat.release();/%s_mat.free();/g" opencv-${OPENCV_VERSION}/modules/java/generator/gen_java.py

sed -i "s/mi.release();/mi.free();/g" opencv-${OPENCV_VERSION}/modules/java/generator/src/java/org/opencv/utils/Converters.java

The result is in this JAR/ZIP with sources: opencv-470.zip

I couldn't identify the location where there is a memory leak, but the process accumulates a lot of memory over time.

I checked all my objects and didn't find any without "free". Do we know of any other memory leak points?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions