c# - XNA - Memory leak while saving frames -


i use xna game project creating frames of 3d scene. got memory leak while using memorystream. code below called part of draw function.

    byte[] framesave()     {         int w = graphicsdevice.presentationparameters.backbufferwidth;         int h = graphicsdevice.presentationparameters.backbufferheight;          //pull picture buffer          int[] backbuffer = new int[w * h];         graphicsdevice.getbackbufferdata(backbuffer);          //copy texture          texture2d texture = new texture2d(graphicsdevice, w, h, false, graphicsdevice.presentationparameters.backbufferformat);         texture.setdata(backbuffer);          memorystream ms = new memorystream();         texture.saveasjpeg(ms, w, h); //memoryleak          byte[] zframe = ms.toarray();          ms.close();         ms.dispose();         texture.dispose();                     return zframe;     } 

any appreciated.

ah found response in other thread:

according texture2d.saveasjpeg (as texture2d.saveaspng) has memory leak. solution (unfortunately) create own texture saving routine.

thanks xna. >.>


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -