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 in core.cu::Render #23

Open
GoogleCodeExporter opened this issue May 12, 2015 · 0 comments
Open

memory leak in core.cu::Render #23

GoogleCodeExporter opened this issue May 12, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Hi, 
I was wondering if you free pDevScene etc. in your rendering call or if it is 
already reimplemented otherwise.

Regardless,
my code looks something like this:


And I found that no dev pointer gets freed, which after several thousand 
iteration fills up the gpu memory to the brim.

best regards
Christoph

void Render(const int& Type, CScene& Scene, CTiming& RenderImageTimer, CTiming& 
BlurImageTimer, CTiming& PostProcessImageTimer, CTiming& DenoiseImageTimer)
{
    CScene* pDevScene = NULL;

    HandleCudaError(cudaMalloc(&pDevScene, sizeof(CScene)), "alloc dev scene failed");
    HandleCudaError(cudaMemcpy(pDevScene, &Scene, sizeof(CScene), cudaMemcpyHostToDevice));

    if (Scene.m_Camera.m_Focus.m_Type == 0)
        Scene.m_Camera.m_Focus.m_FocalDistance = NearestIntersection(pDevScene);

    HandleCudaError(cudaMemcpy(pDevScene, &Scene, sizeof(CScene), cudaMemcpyHostToDevice));

    CCudaView* pDevView = NULL;

    HandleCudaError(cudaMalloc(&pDevView, sizeof(CCudaView)));
    HandleCudaError(cudaMemcpy(pDevView, &gRenderCanvasView, sizeof(CCudaView), cudaMemcpyHostToDevice));


    CCudaInstantRadiosity* pDevIR= NULL;

    HandleCudaError(cudaMalloc(&pDevIR, sizeof(CCudaInstantRadiosity)));
    HandleCudaError(cudaMemcpy(pDevIR, &gInstantRadiosity, sizeof(CCudaInstantRadiosity), cudaMemcpyHostToDevice));


    CCudaTimer TmrRender;

    bool VPLRender = true;  
    switch (VPLRender)
    {
        case false:
        {
            SingleScattering(&Scene, pDevScene, pDevView);
            break;
        }

        case true:
        {
            RenderVPL(&Scene, pDevScene, pDevIR, gpVPLArray, gpAVSMArray, pDevView);        
            break;
        }
    }

    HandleCudaError(cudaFree(pDevIR),"Error freeing pDevIR");

    RenderImageTimer.AddDuration(TmrRender.ElapsedTime());

    CCudaTimer TmrBlur;
    Blur(&Scene, pDevScene, pDevView);
    BlurImageTimer.AddDuration(TmrBlur.ElapsedTime());

    CCudaTimer TmrPostProcess;
    Estimate(&Scene, pDevScene, pDevView);
    PostProcessImageTimer.AddDuration(TmrPostProcess.ElapsedTime());

    ToneMap(&Scene, pDevScene, pDevView);

    CCudaTimer TmrDenoise;
    Denoise(&Scene, pDevScene, pDevView);
    DenoiseImageTimer.AddDuration(TmrDenoise.ElapsedTime());


    HandleCudaError(cudaFree(pDevView),"Error freeing pDevView");
    HandleCudaError(cudaFree(pDevScene),"Error freeing pDevScene");

}

Original issue reported on code.google.com by c.web...@yahoo.de on 10 Aug 2012 at 1:07

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

No branches or pull requests

1 participant