Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

47 lines (30 sloc) 1.535 kb

node-autoreleasepool

A very simple wrapper around the OS X NSAutoreleasePool, for NodeJS.

This module offers dead-simple NSAutoreleasePool functionality. It's more likely meant for use by other Objective-C native modules, so that multiple autorelease pools don't have to be created constantly.

This module takes care of creating an NSAutoreleasePool the first time it's required that may be used automatically by any other Objective-C calls that require one.

It also hooks onto the process's 'exit' event in order to drain the shared autorelease pool at the last possible moment.

Dead-Simple Usage

// Takes care of setting up a shared NSAutoreleasePool
require('autoreleasepool');

// Now do other things in Obj-C land and the runtime won't display
// the "no autorelease pool, just leaking" message.

API

If, for some weird reason, you need to create another NSAutoreleasePool instance, it's simple to do so:

var pool = new autoreleasepool.AutoreleasePool();

The most recent autoreleasepool in the call stack is the one used when creating new Objective-C objects with autorelease.

The only function available to the NSAutoreleasePool instance is drain(), which drains the autorelease pool, and should be called when the program is exiting.

Jump to Line
Something went wrong with that request. Please try again.