4 Replies Latest reply on Jul 8, 2008 3:31 PM by fucrate

    Memory Profiler Leak?

      I'm having trouble with the Flex 3 memory profiler, the memory graph is showing me what is clearly a memory leak of some sort. If I run my app with the memory profiler enabled, the memory will increase until the app crashes which takes about 10 minutes.

      This would be a pretty straightforward case of poor programming on my part except that when I run the app without the memory profiler enabled, or on the web or in the standalone player or in debug mode, there's no memory leak, or at least not such a severe one. Furthermore, by watching the Live Objects it seems that the memory usage isn't increasing, objects stay pretty static except for the usual slight shift due to objects coming and going from memory. This is a pretty confusing problem and seems to be a bug with the profiler, but I'm probably doing something stupid to set it off and running like this.

      Has anyone ever seen this happen to them? Any tips?

      Thanks in advance.
        • 1. Memory Profiler Leak?
          ----------------From Flex Builder Help---------------------------------------------------
          One approach to identifying a memory leak is to first find a discrete set of steps that you can do over and over again with your application, where memory usage continues to grow. It is important to do that set of steps at least once in your application before taking the initial memory snapshot so that any cached objects or other instances are included in that snapshot.
          Then you perform that set of steps in your application a particular number of times -- 3, 7, or some other prime number -- and take the second memory snapshot to compare with the initial snapshot. In the Find Loitering Objects view, you might find loitering objects that have a multiple of 3 or 7 instances. Those objects are probably leaked objects. You double-click the classes to see the stack traces for each of the instances.

          Another approach is to repeat the sequence of steps over a long period of time and wait until the memory usage reaches a maximum. If it does not increase after that, there is no memory leak for that set of steps.
          ------------------------------------------------------------------------------------------ ------------
          check your app following these instructions above.
          • 2. Re: Memory Profiler Leak?
            fucrate Level 1
            Thanks for the help, but the problem isn't actually solving the memory leak, I'm pretty good at that when I have good tools. My problem is that just using Flex's Memory Profiler causes a huge leak for seemingly no reason. If I use the System.totalMemory in my app when in debug mode or in a browser there's very little memory leakage. If I run my app using the flex memory profiler, there's suddenly a huge leak that crashes the game within minutes.
            • 3. Re: Memory Profiler Leak?
              fucrate Level 1
              Ok, just as an update in case it makes it easier for someone to help me I've found that what's taking up all the memory is a number of string instances. For some reason my app is creating and holding on to about 4000 strings every 45 seconds or so.

              Just as one step I changed as many String.match() comparisons as I could into simple == operations which had no result. I do a lot of string comparison to static values, like
              if( thisString == "value") ...
              I don't know if the profiler is somehow keeping those values around somewhere or what...
              • 4. Re: Memory Profiler Leak?
                fucrate Level 1
                Another idea I just had, my app uses sockets to send strings to a server for network communication, maybe the profiler is holding on to all the socket messages? It uses sockets to communicate with the app, right?