Community
cancel
Showing results for 
Search instead for 
Did you mean: 
samontab
Valued Contributor II
150 Views

Memory leak in PXCProjection::CreateColorImageMappedToDepth

It seems that there is a memory leak in the implementation of the PXCProjection::CreateColorImageMappedToDepth method.

After every call, the memory usage increases, even though all the resources are being released.

Actually, if I swap CreateColorImageMappedToDepth  for the other method, CreateDepthImageMappedToColor, everything runs fine with no memory leaks whatsoever.

This suggests that there is a memory leak on the method, at least on v3.3 of the SDK.

 

0 Kudos
10 Replies
Xusheng_L_Intel
Employee
150 Views

I think it is a bug and we will fix it in the future release. Thanks for supporting RealSense SDK.

Tim_T_
Beginner
150 Views

I'm experiencing the same memory leak issue with  CreateColorImageMappedToDepth.   Any guess as to when it will be fixed?   I'm able to use CreateDepthImageMappedToColor as a workaround.

    ...Tim...

samontab
Valued Contributor II
150 Views

Hi Tim,

You could use CreateDepthImageMappedToColor as that methods works fine, but it will give you an image that matches the color camera, not the depth camera, so you will end up with a smaller field of view.

That method returns a depth image aligned with the color image. Now you can just set every non zero pixel to the rgb value of its corresponding pixel in the color image (they are matched, so you can just use the same pixel coordinates).

Tim_T_
Beginner
150 Views

Thanks, yes, I'm able to use CreateDepthImageMappedToColor for the moment.  As you say, it gives a smaller field of view, so it'll be nice when the CreateColorImageMappedToDepth is fixed.

samontab
Valued Contributor II
150 Views

Well, in theory you should be able to get the extrinsic parameter of the cameras by calibrating them yourself. You have the raw IR and the color images so you could match them, and get the KRT matrices. Once you get those, you should be able to implement the method yourself.

It would be nice to have it fixed in the SDK though.

Markus_P_1
Beginner
150 Views

Hi,

 

@Hans: did you make sure that you actually call Release() on the PXCImage you receive from the CreateDepthImageMappedToColor() ?

 

Best,

Markus

samontab
Valued Contributor II
150 Views

I just tested this on the latest SDK, R3 (v5.0), and it is working fine. No more memory leaks present in CreateColorImageMappedToDepth.

Anastasia_T_
Beginner
150 Views

Hello,

I have found the memory leak still persists in newest version of RealSense SDK (intel_rs_sdk_offline_package_r6_8.0.24.6528)."

When I run the provided code sample "...RSSDK/sample/DF_Projection/",  and choose "CreateColorImageMappedToDepth" from the user interface, the task manager of my PC reports 100MB increase of memory consumption every second, till the used memory reaches 1.6Gb, afterwards the mapped image stops updating.

Could you please fix this in the next release or give me a link to the previous release the does not have this memory leak? 

There is no memory leak in CreateDepthImageMappedToColor, but I cannot use it instead in my application, I need CreateColorImageMappedToDepth without a memory leak.

Thank you in advance,

Best regards

Anastasia

Gaofeng_L_
Beginner
150 Views

David Lu (Intel) wrote:

I think it is a bug and we will fix it in the future release. Thanks for supporting RealSense SDK.

 

Hi, David,

      I'm using the F200 camera and I also meet the memory leak problem when I use PXCProjection:CreateColorImageMappedToDepth. My SDK version is 10.0 and my camera model is F200; My code is shown below:

Mat Camera::CreateColorMappedToDepth(PXCImage *color, PXCImage *depth){
	PXCImage* colorToDepthImage =  this->projection->CreateColorImageMappedToDepth(depth, color);

	PXCImage::ImageData colorToDepth;
	this->retStatus = colorToDepthImage->AcquireAccess(PXCImage::ACCESS_READ, PXCImage::PIXEL_FORMAT_RGB24, PXCImage::ROTATION_0_DEGREE, PXCImage::OPTION_ANY, &colorToDepth);
	if(this->retStatus < PXC_STATUS_NO_ERROR){
		std::cout<<"Camera::CreateColorMappedToDepth(PXCImage *color, PXCImage *depth): Error when export data"<<endl;
		std::cout<<"Error Code: "<<this->retStatus<<endl;
		exit(0);
	}
	Mat colorToDepthMat(Size(colorToDepthImage->QueryInfo().width, colorToDepthImage->QueryInfo().height), CV_8UC3, colorToDepth.planes[0]);

	colorToDepthImage->Release();
	return colorToDepthMat;
}

 

"Camera" is a class I defined to obtain and process the color and depth image. I can get the image data and I can also map the color image to the depth image. But the memory increases about 100MB every second. There is the same problem for the CreatDepthImageMappedToColor.

Could you help me?

Alex_P_5
Beginner
150 Views

Looks like CreateDepthImageMappedToColor has also a memory leak. Tested with SDK R3 and R2

 

Reply