[webkit-dev] JSxxxRelease/Retain - some guidance?

Maciej Stachowiak mjs at apple.com
Thu Mar 26 12:35:00 PDT 2009

On Mar 26, 2009, at 8:27 AM, Patrick Mueller wrote:

> Looking at JavaScriptCore APIs, the doc on the Release/Retain  
> functions for JSGlobalContext, JSClass, and JSString are  
> underwhelming.  I'm wondering if someone can provide me a pointer to  
> guidance on usage.
> There are two things I'm thinking of here.  I'm familiar from Java  
> JNI and other 'native' bindings for languages for the needs of  
> 'pinning' objects both to keep them from moving and/or keep them  
> from being GC'd.  Release/Retain could be related to that.
> OTOH, I know there's some kind of Release/Retain dance in the  
> ObjectiveC world as it relates to the memory management scheme of  
> using pools to manage memory.  Release/Retain could be related to  
> that.
> Guessing the second, as there isn't a Release/Retain story for  
> JSObject/JSValue itself, for instance.  If I'm doing straight up C  
> programming, no Cocoa, or Obj-C stuff at all, do I need to worry  
> about this stuff at all, or is there a common pattern I should be  
> using?  Do I NEED to be using memory pools (or whatever they're  
> called) to be doing kosher memory management for, say, long-lived  
> processes where these Retain-able things are coming and going?

JSValueRef/JSObjectRef is garbage collected. The other kinds of values  
are reference counted. Retain increases the refcount and Release  
lowers it.


More information about the webkit-dev mailing list