Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opengl 从cv::GPU::GpuMat复制时,cv::ogl::Texture2D可能存在GPU内存泄漏?_Opengl_Opencv_Memory Leaks - Fatal编程技术网

Opengl 从cv::GPU::GpuMat复制时,cv::ogl::Texture2D可能存在GPU内存泄漏?

Opengl 从cv::GPU::GpuMat复制时,cv::ogl::Texture2D可能存在GPU内存泄漏?,opengl,opencv,memory-leaks,Opengl,Opencv,Memory Leaks,当我调用cv::ogl::Texture2D的copyFrom方法时,我注意到GPU/cuda内存使用量明显增加。这是opencv的错误还是我做错了什么 代码片段如下所示: cv::ogl::Texture2D ofTexU; cv::ogl::Texture2D ofTexV; ofTexU.create( cv::Size( imgW, imgH), cv::ogl::Texture2D::Format::RGB ); ofTexV.create( cv::Size( imgW, imgH

当我调用cv::ogl::Texture2D的copyFrom方法时,我注意到GPU/cuda内存使用量明显增加。这是opencv的错误还是我做错了什么

代码片段如下所示:

cv::ogl::Texture2D ofTexU; 
cv::ogl::Texture2D ofTexV;
ofTexU.create( cv::Size( imgW, imgH), cv::ogl::Texture2D::Format::RGB );
ofTexV.create( cv::Size( imgW, imgH), cv::ogl::Texture2D::Format::RGB );

cv::gpu::GpuMat gpuMatU;
cv::gpu::GpuMat gpuMatV;
gpuMatU.create( cv::Size( imgW, imgH), CV_32FC3 );
gpuMatV.create( cv::Size( imgW, imgH), CV_32FC3 );

...// some processing code

while( 1 ) {
    // The following two lines introduced GPU memory increase, and it's keep increasing
    // If commented out, everything looks fine
    ofTexU.copyFrom( gpuMatU );
    ofTexV.copyFrom( gpuMatV );
}
顺便说一句,我使用cudaMemGetInfo获取GPU内存使用情况,如下所示。我使用的是OpenCV 2.4.6,它是用OpenGL和Cuda支持编译的

size_t free_byte, total_byte ;
cudaError cuda_status = cudaMemGetInfo( &free_byte, &total_byte ) ;
if ( cudaSuccess != cuda_status ){
    printf("Error: cudaMemGetInfo fails, %s \n", cudaGetErrorString(cuda_status) );
    exit(1);
}

这是一个错误。谢谢你的报告。我提交了一个修补程序,可以解决此问题: