none
MultiSourceFrameReader Memory Allocation RRS feed

  • Question

  • We’re currently working on optimizing our code and are having some issues with disposing the MultiSourceFrameReader (MSFR) and the memory allocated to it when opening multiple windows. As of now, we’re only obtaining the body and color data, manipulating each in their own “using” statements, and disposing of the MSFR upon our window closing event. When our window closes it enters into an application launcher that allows the user to re-launch the previous application, opening the window again. As a result, it appears that the memory allocated to the MSFR isn’t being released by the program. The only way to free this memory, that we’ve found, is to exit the entire application and re-open it. Is there another technique other than what we’re using? Or does the MSFR’s Dispose() work differently than the other frame’s Dispose calls? Any feedback would be great.
    Tuesday, February 3, 2015 7:44 PM

All replies

  • Do you see the same behavior if you run the coordinate mapping sample? What do you mean by memory allocation? MSFR doesn't hold onto any frame data as this would starve the runtime. We would prevent your application from getting more frames if you were not releasing the frame objects fast enough. Are you allocating new buffers on every frame in your code? When running the sample, I see the memory consumption to level off around 69MB on my system. 

    When you close the window, have you released/disposed of other objects you may have created on launching the window? 

    Remember .Net uses non deterministic finalization. Even though you may call dispose on an objet the GC/runtime decide when to release that memory. If objects have been promoted to Gen 1/2 the only way to clear them is with an application restart. There are memory profiling objects


    Carmine Sirignano - MSFT

    Wednesday, February 4, 2015 2:19 PM