Skip to content

Instantly share code, notes, and snippets.

@GrahamBorland
Created October 29, 2019 10:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Helper functions for memory management with J2V8
/**
* This executes the supplied lambda in the scope of a J2V8 MemoryManager, ensuring that all
* V8Object instances allocated in the scope are cleaned up on exit.
*/
inline fun <T> V8.scope(body: () -> T) : T {
val scope = MemoryManager(this)
try {
return body()
} finally {
scope.release()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment