Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak when using Threads #83

Open
1nFl4me2 opened this issue Jun 26, 2018 · 2 comments
Open

Memory Leak when using Threads #83

1nFl4me2 opened this issue Jun 26, 2018 · 2 comments

Comments

@1nFl4me2
Copy link

Hi,

When i create a new caffe::Net object in a Thread the memory is not freed.

Below example without Thread works fine and frees memory:

int main()
{
     for(int i=0;i<10;i++)
    {
        caffe::Net* cnn = new caffe::Net(("deploy.prototxt"));
        delete cnn;
    }
    std::cin.ignore();
    return 0;
}

The below example using Threads doesn't free memory

void threadWork()
{
        caffe::Net* cnn = new caffe::Net(("deploy.prototxt"));
        delete cnn;
}

int main()
{
     for(int i=0;i<10;i++)
    {
        std::thread t1(threadWork);
        t1.join();
    }
    std::cin.ignore();
    return 0;
}

Do you know what is causing this?

@luoyetx
Copy link
Owner

luoyetx commented Jun 29, 2018

memory pool manager is used for every thread, and these instances only freed when the program exit.
check the code here and here

@Lin427
Copy link

Lin427 commented Oct 10, 2019

为什么在我的程序里面delete cnn就出错?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants