[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/master] Fix a memory leak in RTMFPSocket.



commit 54bb6795dd0879027498a0a105d976616d2dc8f8
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Mon Jul 18 06:33:51 2011 +0000

    Fix a memory leak in RTMFPSocket.
    
    There was a ByteArray that always grew. When the array has been emptied,
    it's safe to collapse it back down to 0 bytes. This was being done
    before but it was in the wrong place.
---
 RTMFPSocket.as |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/RTMFPSocket.as b/RTMFPSocket.as
index e91d06d..4de3502 100644
--- a/RTMFPSocket.as
+++ b/RTMFPSocket.as
@@ -157,11 +157,6 @@ package
             event.bytesLoaded = bytes.bytesAvailable;
 
             bytes.readBytes(buffer, buffer.length, bytes.bytesAvailable);
-            if (bytes.bytesAvailable == 0) {
-                /* Reclaim memory space. */
-                bytes.position = 0;
-                bytes.length = 0;
-            }
 
             dispatchEvent(event);
         }
@@ -194,6 +189,11 @@ package
         public function readBytes(output:ByteArray, offset:uint = 0, length:uint = 0):void
         {
             buffer.readBytes(output, offset, length);
+            if (buffer.bytesAvailable == 0) {
+                /* Reclaim memory space. */
+                buffer.position = 0;
+                buffer.length = 0;
+            }
         }
 
         public function writeBytes(input:ByteArray, offset:uint = 0, length:uint = 0):void

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits