8000 Memory Leak when using Threads · Issue #83 · luoyetx/mini-caffe · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jul 3, 2025. It is now read-only.

Memory Leak when using Threads #83

Open

Description

@1nFl4me2

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?

Activity

  1. luoyetx commented on Jun 29, 2018

    @luoyetx
    Owner

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

  2. Lin427 commented on Oct 10, 2019

    @Lin427

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      0