Memory leak on close

Hello,
I’m trying to port the hello_xr sample in an existing OpenGL project on Windows. I use SteamVR runtime.
I’ve merge OpenGLGraphicsPlugin & IOpenXrProgram in one class which is used with a std::shared_ptr in my application. But I have some memory leak when I close the application whereas the desctructor is called. I’ve tried to debug the closing of my class but I’ve find nothing.
Have you some ideas to debug more ? Or is a bad idea to merge OpenGLGraphicsPlugin & IOpenXrProgram in one class ?

Thanks

class RenderDeviceVR
{
public:
   RenderDeviceVR(IGrRender* pRenderer);
   virtual ~RenderDeviceVR(); // contains all xrDestroy

   void CreateInstance();
   void InitializeSystem(HDC hdc, HGLRC hglrc);
   void InitializeSession();
   void CreateSwapchains(const std::array<int64_t, 4>& arSupportedColorSwapchainFormats);
   bool RenderFrame();

   bool IsInstanceValid() const;
   bool IsSessionRunning() const;
   bool IsSessionFocused() const;
   bool HaveExtensionsAvailable() const;

   std::function<void(const XrMatrix4x4f&, const XrMatrix4x4f&)> m_fnRenderFrame;

   HDC   GetHDC() const;
   HGLRC GetHGLRC() const;

private:
   // CreateInstance
   void CreateInstanceInternal();

   // InitializeSystem
   void InitializeDevice(HDC hdc, HGLRC hglrc);

   // InitializeSession
   void InitializeActions();
   void CreateVisualizedSpaces();

   // RenderFrame
   void PollEvents(bool& bExitRenderLoop, bool& bRequestRestart);
   void PollActions(/*const XrTime& Time*/);
   void UpdateMatrix(const XrCompositionLayerProjectionView& arLayerViews);
   bool RenderLayer(XrTime PredictedDisplayTime, std::vector<XrCompositionLayerProjectionView>& arProjectionLayerViews, XrCompositionLayerProjection& Layer);

   // PollEvents
   const XrEventDataBaseHeader* TryReadNextEvent();
   void HandleSessionStateChangedEvent(const XrEventDataSessionStateChanged& StateChangedEvent, bool& bExitRenderLoop, bool& bRequestRestart);

   // Log
   void LogActionSourceName(XrAction Action, const std::string& sActionName) const;
   void LogInstanceInfo();
   void LogViewConfigurations();
   void LogEnvironmentBlendMode(XrViewConfigurationType Type);
   void LogReferenceSpaces();

   IGrRender* m_pRenderer;

   XrGraphicsBindingOpenGLWin32KHR m_GraphicsBinding;

   XrInstance     m_Instance;
   XrSession      m_Session;
   XrSpace        m_AppSpace;
   XrSystemId     m_SystemId;
   XrSessionState m_SessionState;
   bool m_bSessionRunning;

   XrFormFactor m_FormFactor;
   XrViewConfigurationType m_ViewConfigType;
   XrEnvironmentBlendMode m_EnvironmentBlendMode;

   std::list<std::vector<XrSwapchainImageOpenGLKHR>> m_arSwapchainImageBuffers;

   std::vector<XrSpace> m_arVisualizedSpaces;
   std::vector<Swapchain> m_arSwapchains;
   std::vector<XrViewConfigurationView> m_arConfigViews;
   std::vector<XrView> m_arViews;
   std::map<XrSwapchain, std::vector<XrSwapchainImageBaseHeader*>> m_mapSwapchainImages;

   int64_t m_iColorSwapchainFormat;

   XrEventDataBuffer m_EventDataBuffer;
   InputState m_InputState;

   XrMatrix4x4f m_trfProjection;
   XrMatrix4x4f m_trfModelView;
};
Detected memory leaks!
Dumping objects ->
{1867430} normal block at 0x000002114B432FD0, 40 bytes long.
 Data: < { K    `~!K    > 00 7B 0A 4B 11 02 00 00 60 7E 21 4B 11 02 00 00 
{1867429} normal block at 0x000002114B217E60, 32 bytes long.
 Data: <XR_KHR_opengl_en> 58 52 5F 4B 48 52 5F 6F 70 65 6E 67 6C 5F 65 6E 
{1867428} normal block at 0x000002114B0A7B00, 16 bytes long.
 Data: < /CK            > D0 2F 43 4B 11 02 00 00 00 00 00 00 00 00 00 00 
{1867427} normal block at 0x0000021143BFBA60, 1360 bytes long.
 Data: <0  F            > 30 91 B4 46 FE 7F 00 00 00 00 00 00 00 00 00 00 
{1867425} normal block at 0x000002114B0A7060, 16 bytes long.
 Data: <   C            > 98 E2 82 43 11 02 00 00 00 00 00 00 00 00 00 00 
{1867423} normal block at 0x000002114382E280, 104 bytes long.
 Data: < t F     I K    > B0 74 C5 46 FE 7F 00 00 10 49 05 4B 11 02 00 00 
{1865108} normal block at 0x0000021143CB7E90, 16 bytes long.
 Data: <   C            > B8 E2 82 43 11 02 00 00 00 00 00 00 00 00 00 00 
Object dump complete.
The program '[27252] app.exe' has exited with code 0 (0x0).

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.