A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Memory leak writing string to file

  1. #1
    Registered User
    Join Date
    Feb 2018
    Posts
    1

    Post Memory leak writing string to file

    Using the windows process explorer I can see that memory in my program goes up, then gets collected and drops back down in a constant loop until I uncomment the following function:

    Code:
    protected function marker( output:FileStream, file:File, i:int, j:int ):void
    {
    	output.open( file, FileMode.APPEND );
    	output.writeUTFBytes( i + "\t" + j + "\n" );	
    	output.close();				
    }
    With this function being called, the memory increases unboundedly until it reaches around 2GB and the whole thing crashes with an out of memory error. I was hoping someone could shed some light on where the leak here is and how to fix it, since I would like to be able to call this function reasonably frequently. Thanks. I think it's creating a new String each time but don't know why it's not being collected if this is in fact what's happening.

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    APPEND : String = "append"
    [static] Used for a file to be opened in write mode, with all written data appended to the end of the file.
    https://help.adobe.com/en_US/FlashPl.../FileMode.html
    You should make sure what you want to use. Append probably just keeps adding to the file until it gets too big. I figure that the file you try opening ends up being too big.
    .

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center