diff options
| author | Andre Weissflog <floooh@gmail.com> | 2021-05-31 19:14:22 +0200 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2021-05-31 19:14:22 +0200 |
| commit | bc64d6f2666b68729cb5f5208a8b0e29d35eba25 (patch) | |
| tree | 8da5188cc14845154022afd1caa4d5e684e7db00 | |
| parent | 15c95969dad8ef72bd13c2e8bdd89495a6f32bda (diff) | |
sokol_app.h macos gl: fix NSOpenGLContext memory leak
| -rw-r--r-- | sokol_app.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/sokol_app.h b/sokol_app.h index 2952aaa8..965b5295 100644 --- a/sokol_app.h +++ b/sokol_app.h @@ -3787,8 +3787,10 @@ _SOKOL_PRIVATE bool _sapp_macos_create_window(_sapp_window_t* win) { win->macos.view.win_id = win->slot.id; if (nil != shared_main_context) { // create a new NSOpenContext which shares resources with the main window's context - win->macos.view.openGLContext = [[NSOpenGLContext alloc] initWithFormat:nsglpixelformat_obj shareContext:shared_main_context]; - SOKOL_ASSERT(nil != win->macos.view.openGLContext); + NSOpenGLContext* nsgl_context = [[NSOpenGLContext alloc] initWithFormat:nsglpixelformat_obj shareContext:shared_main_context]; + SOKOL_ASSERT(nsgl_context); + win->macos.view.openGLContext = nsgl_context; + _SAPP_OBJC_RELEASE(nsgl_context); } _SAPP_OBJC_RELEASE(nsglpixelformat_obj); [win->macos.view updateTrackingAreas]; @@ -3821,9 +3823,6 @@ _SOKOL_PRIVATE bool _sapp_macos_create_window(_sapp_window_t* win) { } _SOKOL_PRIVATE void _sapp_macos_destroy_window(_sapp_window_t* win) { - -// FIXME FIXME FIXME: the GL backend currently has a ~7MB memory leak on window destruction - SOKOL_ASSERT(win); // NOTE: it's safe to call [release] on a nil object _SAPP_OBJC_RELEASE(win->macos.tracking_area); |