FB Profile says "it is a gc root", but it seems wrong?

336 views Asked by At

People like flash builder profile tool very much.But recently, a problem came to me when I tried to find a memory leak. Here is the simplified sample.

package
{
    import flash.display.Sprite;
    import flash.sampler.pauseSampling;
    import flash.system.System;

    import org.robotlegs.base.ContextBase;
    import org.robotlegs.mvcs.Context;

    public class MemoryLeak extends Sprite
    {
        public function MemoryLeak()
        {
            makeAndDrop();
        }

        public function makeAndDrop():void{
            var _context : Context = new Context(this);
            _context = null;
        }
    }
}

This is a simple class that create an object and then release it. When I use the profile perspective, it show me "live objects". enter image description here This is expected since I know that GC will free an object only when it doesn't have enough memory. Then I take a snapshot, to see the weird thing: Before I expand the path, it is like this: enter image description here And I am interested in the holder of context object, so I expand it: enter image description here That's so strange! As you see, nothing holds a reference to it.And it is implied to be a "GCRoot". I know articles about gc root, and it's quite simple(I read up to 20 articles about GC strategy to ensure my comprehension).It is no possible that the context is a gc root. And what's more, this isn't "1 path" at all! I hope it's a bug of profile tool, but I do want some explanations. So please forget about the "why not collect issue". I hope somebody tell me why the profile tool say"context is an gc root".Is it a bug or something? PS: I use flash builder 4.6 and flash debugger 11 sa.

0

There are 0 answers