11 Replies Latest reply on Mar 2, 2017 12:06 AM by MartyG

    visual studio 2015 display SR300 colorstrem then memory overload

    Edsion_Wu

      Hi, Sir

       

      I'm beginner.

       

      I got the color-stream by SR300 , then the image do Bi-level image and algorithm.

       

      when i display the image about 5 min ,the error message show out "memory overload".

       

      Could you  give me some suggestion about program method ?

       

      thanks.

       

      edison.

      .

        • 1. Re: visual studio 2015 display SR300 colorstrem then memory overload
          MartyG

          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.

           

          QueryVertices

          • 2. Re: visual studio 2015 display SR300 colorstrem then memory overload
            Edsion_Wu

            Hi, MartyG

             

            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

             

             

            • 3. Re: visual studio 2015 display SR300 colorstrem then memory overload
              MartyG

              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!

              • 4. Re: visual studio 2015 display SR300 colorstrem then memory overload
                jb455

                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
                • 5. Re: visual studio 2015 display SR300 colorstrem then memory overload
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hi Edison_Wu

                  Do you still need assistance with this thread?
                  We’ll be waiting for your response.

                  -Sergio A
                   

                  • 6. Re: visual studio 2015 display SR300 colorstrem then memory overload
                    Edsion_Wu

                    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.

                    11.gif

                    and then i un-comment "thread.start" and comment  most of code, the memory is increases.

                    22.gif

                    it's my testing code below ,i will try it form jb455.

                     

                    Thanks for everyone Help.

                    using System;

                    using System.Collections.Generic;

                    using System.ComponentModel;

                    using System.Data;

                    using System.Drawing;

                    using System.Linq;

                    using System.Text;

                    using System.Threading.Tasks;

                    using System.Windows.Forms;

                    using System.Drawing.Imaging;

                     

                     

                    namespace SR300_study

                    {

                        public partial class Form1 : Form

                        {

                            public int WIDTH = 640;

                            public int HEIGHT = 480;

                            public PXCMSession g_session;

                     

                     

                           

                            public Form1()

                            {

                               

                                Form1.CheckForIllegalCrossThreadCalls = false;

                                InitializeComponent();

                                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);

                                thread.Start();

                                //System.Threading.Thread.Sleep(1000);

                            }

                     

                     

                            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);

                     

                     

                                sm.Init();

                     

                     

                                while (sm.AcquireFrame(true).IsSuccessful())

                                {

                     

                     

                                    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

                                    }

                                    sm.ReleaseFrame();

                                }

                            }

                     

                     

                        }

                     

                    }

                    1 of 1 people found this helpful
                    • 7. Re: visual studio 2015 display SR300 colorstrem then memory overload
                      MartyG

                      Thanks so much for sharing this with the community, Edison_Wu 

                      • 8. Re: visual studio 2015 display SR300 colorstrem then memory overload
                        jb455

                        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.

                        • 9. Re: visual studio 2015 display SR300 colorstrem then memory overload
                          Intel Corporation
                          This message was posted on behalf of Intel Corporation

                          Hi Edison_Wu,

                          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!

                          Regards,
                          -Sergio A
                           

                          • 10. Re: visual studio 2015 display SR300 colorstrem then memory overload
                            Edsion_Wu

                            Hi, all

                             

                            Thanks for everyone help.

                             

                            I have solved this problem.

                             

                            @jb455 is right . I did't release image data ,then add below the code in my code .The memory didn't increases.

                            1. image.ReleaseAccess(data); 
                            2. image.Dispose();

                            123.gif"

                            1 of 1 people found this helpful
                            • 11. Re: visual studio 2015 display SR300 colorstrem then memory overload
                              MartyG

                              Great news, thanks for letting us know!