* Bug #11257 fixed - Memory leaks fixed in Scilab graphics. 64/9264/6
Bruno JOFRET [Tue, 25 Sep 2012 12:40:28 +0000 (14:40 +0200)]
Change-Id: Ie8cb67cb40c5d104b2b59877988a1b1117d9eb70

scilab/CHANGES_5.4.X
scilab/modules/graphics/tests/nonreg_tests/bug_11257.dia.ref [new file with mode: 0644]
scilab/modules/graphics/tests/nonreg_tests/bug_11257.tst [new file with mode: 0644]
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/DataManager.java

index 1e5e186..4981a6d 100644 (file)
@@ -94,6 +94,8 @@ Bug Fixes
 
 * Bug #10885 fixed - Renamed "Exit" to "Exit Scinotes" in Scinotes.
 
+* Bug #11257 fixed - Memory leaks fixed in Scilab graphics.
+
 * Bug #11293 fixed - Line style was not taken into account.
 
 * Bug #11298 fixed - Listboxes callback was executed several times for one action.
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_11257.dia.ref b/scilab/modules/graphics/tests/nonreg_tests/bug_11257.dia.ref
new file mode 100644 (file)
index 0000000..9b586f7
--- /dev/null
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Vincent COUVERT
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+// <-- Non-regression test for bug 11257 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11257
+//
+// <-- Short Description -->
+// Memory leaks in Scilab graphics.
+n=1024;
+m=1040;
+a=rand(n,m);
+for i=1:10
+  h=scf();
+  grayplot(1:n,1:m,a);
+  delete(h);
+end
diff --git a/scilab/modules/graphics/tests/nonreg_tests/bug_11257.tst b/scilab/modules/graphics/tests/nonreg_tests/bug_11257.tst
new file mode 100644 (file)
index 0000000..b062314
--- /dev/null
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Vincent COUVERT
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- TEST WITH GRAPHIC -->
+
+// <-- Non-regression test for bug 11257 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11257
+//
+// <-- Short Description -->
+// Memory leaks in Scilab graphics.
+
+n=1024;
+m=1040;
+a=rand(n,m);
+
+for i=1:10
+  h=scf();
+  grayplot(1:n,1:m,a);
+  delete(h);
+end
index 2c80631..8a74899 100644 (file)
@@ -39,99 +39,99 @@ public class DataManager {
      * Set of properties that affect Fac3d data.
      */
     private static final Set<Integer> FAC3D_DATA_PROPERTIES = new HashSet<Integer>(Arrays.asList(
-            GraphicObjectProperties.__GO_DATA_MODEL__,
-            GraphicObjectProperties.__GO_COLOR_FLAG__,
-            GraphicObjectProperties.__GO_COLOR_MODE__,
-            GraphicObjectProperties.__GO_DATA_MAPPING__
-    ));
+                GraphicObjectProperties.__GO_DATA_MODEL__,
+                GraphicObjectProperties.__GO_COLOR_FLAG__,
+                GraphicObjectProperties.__GO_COLOR_MODE__,
+                GraphicObjectProperties.__GO_DATA_MAPPING__
+            ));
 
     /**
      * Set of properties that affect Fec data.
      */
     private static final Set<Integer> FEC_DATA_PROPERTIES = new HashSet<Integer>(Arrays.asList(
-            GraphicObjectProperties.__GO_DATA_MODEL__,
-            GraphicObjectProperties.__GO_Z_BOUNDS__,
-            GraphicObjectProperties.__GO_COLOR_RANGE__,
-            GraphicObjectProperties.__GO_OUTSIDE_COLOR__
-    ));
+                GraphicObjectProperties.__GO_DATA_MODEL__,
+                GraphicObjectProperties.__GO_Z_BOUNDS__,
+                GraphicObjectProperties.__GO_COLOR_RANGE__,
+                GraphicObjectProperties.__GO_OUTSIDE_COLOR__
+            ));
 
     /**
      * Set of properties that affect Grayplot data.
      */
     private static final Set<Integer> GRAYPLOT_DATA_PROPERTIES = new HashSet<Integer>(Arrays.asList(
-            GraphicObjectProperties.__GO_DATA_MODEL__,
-            GraphicObjectProperties.__GO_DATA_MAPPING__
-    ));
+                GraphicObjectProperties.__GO_DATA_MODEL__,
+                GraphicObjectProperties.__GO_DATA_MAPPING__
+            ));
 
     /**
      * Set of properties that affect Matplot data.
      */
     private static final Set<Integer> MATPLOT_DATA_PROPERTIES = new HashSet<Integer>(Arrays.asList(
-            GraphicObjectProperties.__GO_DATA_MODEL__
-    ));
+                GraphicObjectProperties.__GO_DATA_MODEL__
+            ));
 
     /**
      * Set of properties that affect polyline data.
      */
     private static final Set<Integer> POLYLINE_DATA_PROPERTIES = new HashSet<Integer>(Arrays.asList(
-            GraphicObjectProperties.__GO_DATA_MODEL__,
-            GraphicObjectProperties.__GO_POLYLINE_STYLE__,
-            GraphicObjectProperties.__GO_LINE_MODE__,
-            GraphicObjectProperties.__GO_BAR_WIDTH__,
-            GraphicObjectProperties.__GO_CLOSED__,
-            GraphicObjectProperties.__GO_FILL_MODE__,
-            GraphicObjectProperties.__GO_INTERP_COLOR_VECTOR__,
-            GraphicObjectProperties.__GO_INTERP_COLOR_MODE__
-    ));
+                GraphicObjectProperties.__GO_DATA_MODEL__,
+                GraphicObjectProperties.__GO_POLYLINE_STYLE__,
+                GraphicObjectProperties.__GO_LINE_MODE__,
+                GraphicObjectProperties.__GO_BAR_WIDTH__,
+                GraphicObjectProperties.__GO_CLOSED__,
+                GraphicObjectProperties.__GO_FILL_MODE__,
+                GraphicObjectProperties.__GO_INTERP_COLOR_VECTOR__,
+                GraphicObjectProperties.__GO_INTERP_COLOR_MODE__
+            ));
 
     /**
      * Set of properties that affect Plot3d data.
      */
     private static final Set<Integer> PLOT3D_DATA_PROPERTIES = new HashSet<Integer>(Arrays.asList(
-            GraphicObjectProperties.__GO_DATA_MODEL__
-    ));
+                GraphicObjectProperties.__GO_DATA_MODEL__
+            ));
 
     /**
      * Set of properties that affect Arc data.
      */
     private static final Set<Integer> ARC_DATA_PROPERTIES = new HashSet<Integer>(Arrays.asList(
-            GraphicObjectProperties.__GO_UPPER_LEFT_POINT__,
-            GraphicObjectProperties.__GO_WIDTH__,
-            GraphicObjectProperties.__GO_HEIGHT__,
-            GraphicObjectProperties.__GO_START_ANGLE__,
-            GraphicObjectProperties.__GO_END_ANGLE__
-    ));
+                GraphicObjectProperties.__GO_UPPER_LEFT_POINT__,
+                GraphicObjectProperties.__GO_WIDTH__,
+                GraphicObjectProperties.__GO_HEIGHT__,
+                GraphicObjectProperties.__GO_START_ANGLE__,
+                GraphicObjectProperties.__GO_END_ANGLE__
+            ));
 
     /**
      * Set of properties that affect Champ data.
      */
     private static final Set<Integer> CHAMP_DATA_PROPERTIES = new HashSet<Integer>(Arrays.asList(
-            GraphicObjectProperties.__GO_BASE_X__,
-            GraphicObjectProperties.__GO_BASE_Y__,
-            GraphicObjectProperties.__GO_BASE_Z__,
-            GraphicObjectProperties.__GO_DIRECTION_X__,
-            GraphicObjectProperties.__GO_DIRECTION_Y__,
-            GraphicObjectProperties.__GO_DIRECTION_Z__,
-            GraphicObjectProperties.__GO_COLORED__
-    ));
+                GraphicObjectProperties.__GO_BASE_X__,
+                GraphicObjectProperties.__GO_BASE_Y__,
+                GraphicObjectProperties.__GO_BASE_Z__,
+                GraphicObjectProperties.__GO_DIRECTION_X__,
+                GraphicObjectProperties.__GO_DIRECTION_Y__,
+                GraphicObjectProperties.__GO_DIRECTION_Z__,
+                GraphicObjectProperties.__GO_COLORED__
+            ));
 
     /**
      * Set of properties that affect Rectangle data.
      */
     private static final Set<Integer> RECTANGLE_DATA_PROPERTIES = new HashSet<Integer>(Arrays.asList(
-            GraphicObjectProperties.__GO_UPPER_LEFT_POINT__,
-            GraphicObjectProperties.__GO_WIDTH__,
-            GraphicObjectProperties.__GO_HEIGHT__
-    ));
+                GraphicObjectProperties.__GO_UPPER_LEFT_POINT__,
+                GraphicObjectProperties.__GO_WIDTH__,
+                GraphicObjectProperties.__GO_HEIGHT__
+            ));
 
     /**
      * Set of properties that affect Segs data.
      */
     private static final Set<Integer> SEGS_DATA_PROPERTIES = new HashSet<Integer>(Arrays.asList(
-            GraphicObjectProperties.__GO_BASE__,
-            GraphicObjectProperties.__GO_DIRECTION__,
-            GraphicObjectProperties.__GO_SEGS_COLORS__
-    ));
+                GraphicObjectProperties.__GO_BASE__,
+                GraphicObjectProperties.__GO_DIRECTION__,
+                GraphicObjectProperties.__GO_SEGS_COLORS__
+            ));
 
     private static final double[] DEFAULT_SCALE     = new double[] {1, 1, 1};
     private static final double[] DEFAULT_TRANSLATE = new double[] {0, 0, 0};
@@ -366,7 +366,7 @@ public class DataManager {
      * Clears all the color buffers.
      */
     public void disposeAllColorBuffers() {
-       canvas.getBuffersManager().dispose(colorBufferMap.values());
+        canvas.getBuffersManager().dispose(colorBufferMap.values());
         colorBufferMap.clear();
     }
 
@@ -438,10 +438,10 @@ public class DataManager {
     }
 
     private void fillColorBuffer(ElementsBuffer colorBuffer, String id) throws ObjectRemovedException, OutOfMemoryException {
-            int length = MainDataLoader.getDataSize(id);
-            FloatBuffer data = BufferAllocation.newFloatBuffer(length * 4);
-            MainDataLoader.fillColors(id, data, 4);
-            colorBuffer.setData(data, 4);
+        int length = MainDataLoader.getDataSize(id);
+        FloatBuffer data = BufferAllocation.newFloatBuffer(length * 4);
+        MainDataLoader.fillColors(id, data, 4);
+        colorBuffer.setData(data, 4);
     }
 
     private void fillIndexBuffer(IndicesBuffer indexBuffer, String id) throws ObjectRemovedException, OutOfMemoryException {