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 usage is keep increasing at depth estimation stage #6

Open
CanCanZeng opened this issue Sep 19, 2021 · 2 comments
Open

memory usage is keep increasing at depth estimation stage #6

CanCanZeng opened this issue Sep 19, 2021 · 2 comments

Comments

@CanCanZeng
Copy link
Contributor

Hi, thank you for opening this great project! I tested this algorithm on ETH3d training data "kicker", the memory is keep increasing. My computer capacity is 32Gb, and at the end ACMMP use more than 30Gb memory. And in another bigger dataset, the program just killed half way.
I think this should not happen but I don't find the bug, can you help me? And this bug is at depth estimation stage, not depth fusion stage.

@CanCanZeng
Copy link
Contributor Author

I find the causer, there are memory leak problems in readDepthDmb and readNormalDmb functions.
I create a merge pull request, please check it when you are free.

@ss2lyf
Copy link

ss2lyf commented Nov 5, 2021

I changed the code of function readDepthDmb and readNormalDmb in ACMMP.cpp as below:

int readDepthDmb(const std::string file_path, cv::Mat_<float> &depth)
{
    FILE *inimage;
    inimage = fopen(file_path.c_str(), "rb");
    if (!inimage){
        std::cout << "Error opening file " << file_path << std::endl;
        return -1;
    }

    int32_t type, h, w, nb;

    type = -1;

    fread(&type,sizeof(int32_t),1,inimage);
    fread(&h,sizeof(int32_t),1,inimage);
    fread(&w,sizeof(int32_t),1,inimage);
    fread(&nb,sizeof(int32_t),1,inimage);

    if(type != 1){
        fclose(inimage);
        return -1;
    }

    int32_t dataSize = h*w*nb;

    float* data;
    data = (float*) malloc (sizeof(float)*dataSize);
    fread(data,sizeof(float),dataSize,inimage);

    depth = cv::Mat(h,w,CV_32F);

    memcpy(depth.data,data,sizeof(float)*dataSize);
    free(data);

    fclose(inimage);
    return 0;
}

int readNormalDmb (const std::string file_path, cv::Mat_<cv::Vec3f> &normal)
{
    FILE *inimage;
    inimage = fopen(file_path.c_str(), "rb");
    if (!inimage){
        std::cout << "Error opening file " << file_path << std::endl;
        return -1;
    }

    int32_t type, h, w, nb;

    type = -1;

    fread(&type,sizeof(int32_t),1,inimage);
    fread(&h,sizeof(int32_t),1,inimage);
    fread(&w,sizeof(int32_t),1,inimage);
    fread(&nb,sizeof(int32_t),1,inimage);

    if(type != 1){
        fclose(inimage);
        return -1;
    }

    int32_t dataSize = h*w*nb;

    float* data;
    data = (float*) malloc (sizeof(float)*dataSize);
    fread(data,sizeof(float),dataSize,inimage);

    normal = cv::Mat(h,w,CV_32FC3);


    memcpy(normal.data,data,sizeof(float)*dataSize);
    free(data);


    fclose(inimage);
    return 0;
}

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

2 participants