dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnetlib ./ChangeLog runtime/System/Collections/...


From: Heiko Weiss
Subject: [dotgnu-pnet-commits] pnetlib ./ChangeLog runtime/System/Collections/...
Date: Thu, 13 Apr 2006 06:11:19 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnetlib
Branch:         
Changes by:     Heiko Weiss <address@hidden>    06/04/13 06:11:19

Modified files:
        .              : ChangeLog 
        runtime/System/Collections: Stack.cs 

Log message:
        Fixed a memory leak in Stack.Pop() and Stack.Clear()

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/ChangeLog.diff?tr1=1.2381&tr2=1.2382&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/runtime/System/Collections/Stack.cs.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: pnetlib/ChangeLog
diff -u pnetlib/ChangeLog:1.2381 pnetlib/ChangeLog:1.2382
--- pnetlib/ChangeLog:1.2381    Wed Apr 12 17:50:50 2006
+++ pnetlib/ChangeLog   Thu Apr 13 06:11:19 2006
@@ -1,3 +1,7 @@
+2006-04-13  Heiko Weiss  <address@hidden>
+
+       * runtime/System/Collections/Stack.cs: Fixed a memory leak in 
Stack.Pop() and Stack.Clear().
+
 2006-04-12  Radek Polak  <address@hidden>
 
        * System.Windows.Forms/TabControl.cs: Fix an IndexOutOfRange exception 
in
Index: pnetlib/runtime/System/Collections/Stack.cs
diff -u pnetlib/runtime/System/Collections/Stack.cs:1.5 
pnetlib/runtime/System/Collections/Stack.cs:1.6
--- pnetlib/runtime/System/Collections/Stack.cs:1.5     Wed Jun  2 06:01:37 2004
+++ pnetlib/runtime/System/Collections/Stack.cs Thu Apr 13 06:11:19 2006
@@ -133,6 +133,13 @@
        // Clear the contents of this stack.
        public virtual void Clear()
                        {
+                               // brubbel
+                               // set all references to zero, to avoid memory 
leaks !!!
+                               int iCount = items.Length;
+                               for( int i = 0; i < iCount; i++ ) {
+                                       items[i] = null;
+                               }
+                               
                                size = 0;
                                ++generation;
                        }
@@ -164,7 +171,10 @@
                                if(size > 0)
                                {
                                        ++generation;
-                                       return items[--size];
+                                       --size;
+                                       Object o = items[size];
+                                       items[size] = null; // remove reference 
of object, to avoid memory leaks !!!
+                                       return o;
                                }
                                else
                                {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]