When you say "memory overload", do you mean the "out of memory" error in Visual Studio 2015?
If you are using the instruction CreateColorImageMappedToDepth or CreateColorImageMappedToColor, these instructions have a known issue with a 'memory leak' that uses up memory over time whilst the program is running until the program crashes. The only solution is to use a different instruction that does not have the leak.
I recommend using the QueryVertices instruction instead to calculate vertices from the depth image.
yes, it's "out of memory" error .
I try to only read RGB stream to display, but it's still show "out of memory" message.
no calculate no algorithm
Could you give more details please about the RealSense script that you are using with Visual Studio 2015, and post it in your message or link to it if it is listed on a website? Is it the 'Rawstreams' sample? Thanks!
1 of 1 people found this helpful
Make sure you're calling ReleaseFrame after QuerySample, Dispose after any CreateX methods (eg, CreateProjection, CreateColorImageMappedToDepth etc - not immediately after, but when you're finished with the result for this frame), and ReleaseAccess after AcquireAccess to avoid memory building up. If you're just doing simple streaming, your code should look something like this:
PXCMCapture.Sample photo = pSenseManager.QuerySample(); PXCMImage image = photo.color; pSenseManager.ReleaseFrame(); PXCMImage.ImageData data; image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB24, out data); form.DisplayBitmap(data.ToBitmap(0, image.info.width, image.info.height)); image.ReleaseAccess(data); image.Dispose();
1 of 1 people found this helpful
Hi, jb455 & MartyG
thanks for your reply .
I think that it's problem about thread .
when I comment the "thread.start" ,and running application . the memory isn't increases.
and then i un-comment "thread.start" and comment most of code, the memory is increases.
it's my testing code below ,i will try it form jb455.
Thanks for everyone Help.
public partial class Form1 : Form
public int WIDTH = 640;
public int HEIGHT = 480;
public PXCMSession g_session;
Form1.CheckForIllegalCrossThreadCalls = false;
pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);
private void button1_Click(object sender, EventArgs e)
System.Threading.Thread thread = new System.Threading.Thread(RGB_DoRecognition);
public void RGB_DoRecognition()
PXCMSenseManager sm = PXCMSenseManager.CreateInstance();
if (sm == null)
MessageBox.Show("sm is null");
sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, WIDTH, HEIGHT, 30);
PXCMCapture.Sample sample = sm.QuerySample();
PXCMImage.ImageData data= null;
pxcmStatus ret = sample.color.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB24, out data);
if (ret == pxcmStatus.PXCM_STATUS_NO_ERROR)
//delete most of the code
Thanks so much for sharing this with the community, Edison_Wu
The docs for AcquireFrame recommend calling ReleaseFrame as soon as possible, without much processing going on in between. I'd suggest, like in my snippet above, taking a copy of the image(s) you need from the sample and calling ReleaseFrame immediately after that. Also be sure to call colourImage.ReleaseAccess(data), and also colourImage.Dispose(), when you are finished with the image data and the image itself.
This message was posted on behalf of Intel Corporation
It’s great to hear you managed to resolve this issue. Feel free to contact us again if help is needed.
@MartyG and @jb455. Thanks so much for helping out!
Great news, thanks for letting us know!