#2 ✓resolved
gus (at flyingmeat)

Big 'ol memory leak

Reported by gus (at flyingmeat) | March 4th, 2009 @ 09:55 PM | in 1.0

Autoreleased objects don't seem to be going away. Run this a bunch of times in JSTalk Editor:

var data = [NSMutableData dataWithLength:1024 * 1024];

Comments and changes to this ticket

  • gus (at flyingmeat)

    gus (at flyingmeat) March 4th, 2009 @ 11:27 PM

    • Milestone set to 1.0
  • Patrick Geiller

    Patrick Geiller March 10th, 2009 @ 09:27 AM

    JSCocoa retains ObjC objects, you need to remove any reference to them to get them released.

    // Retains var data = ...some ObjC object // Make collectable : object will be freed when Javascript GC starts var data = null

    After nulling the reference, you can call JSCocoaController's garbageCollect to manually start Javascript GC - this will release the retained ObjC objects.

  • Patrick Geiller

    Patrick Geiller March 10th, 2009 @ 09:54 AM

    (formatting)

    
    // Retains 
    var data = ...some ObjC object 
    // Make collectable : object will be freed when Javascript GC starts 
    data = null
    
  • gus (at flyingmeat)

    gus (at flyingmeat) March 11th, 2009 @ 12:40 AM

    Oh hey, how about that.

    Is there anyway that we can figure out what objects need to be nulled out when we tear down the JSContextRef? Maybe stick all those values in a hashtable maybe? Or something? Hrm...

  • Patrick Geiller

    Patrick Geiller March 11th, 2009 @ 01:22 PM

    JSCocoaController has unlinkAllReferences. It just nulls everything out :)

    There's also boxedObjects, which you can examine to see what objects are in use.

    To terminate safely and release everything you just need this :

    
    	[jsc unlinkAllReferences];
    	[jsc garbageCollect];
    	[jsc release];
    
  • gus (at flyingmeat)

    gus (at flyingmeat) March 11th, 2009 @ 02:29 PM

    • State changed from “new” to “resolved”

    Yep, that does the trick.

    Thanks Patrick!

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Check out the readme: http://github.com/ccgus/jstalk/tree/master

People watching this ticket

Tags

Pages