ios: Do not leak texture cache objects
authorFrank Osterfeld <frank.osterfeld@kdab.com>
Sun, 22 Feb 2015 12:15:03 +0000 (13:15 +0100)
committerYoann Lopes <yoann.lopes@theqtcompany.com>
Wed, 25 Feb 2015 12:36:38 +0000 (12:36 +0000)
Do not recreate m_textureCache if it already exists. This changes the
memory allocation behavior of a simple iOS example program from
linearly increasing to constant over time.

Change-Id: I6ff13b586c653fb7b4cadfa9f4ebf985b07ee455
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
src/plugins/avfoundation/mediaplayer/avfvideoframerenderer_ios.mm

index 0c8e8c5..b5ad853 100644 (file)
@@ -240,14 +240,16 @@ void AVFVideoFrameRenderer::initRenderer()
     //Need current context
     m_glContext->makeCurrent(m_offscreenSurface);
 
-    //  Create a new open gl texture cache
-    CVReturn err = CVOGLTextureCacheCreate(kCFAllocatorDefault, NULL,
-        [EAGLContext currentContext],
-        NULL, &m_textureCache);
-
-    if (err) {
-#ifdef QT_DEBUG_AVF
-        qWarning("Error at CVOGLTextureCacheCreate %d", err);
-#endif
+    if (!m_textureCache) {
+        //  Create a new open gl texture cache
+        CVReturn err = CVOGLTextureCacheCreate(kCFAllocatorDefault, NULL,
+            [EAGLContext currentContext],
+            NULL, &m_textureCache);
+        if (err) {
+    #ifdef QT_DEBUG_AVF
+            qWarning("Error at CVOGLTextureCacheCreate %d", err);
+    #endif
+        }
     }
+
 }