Helper functions for memory management with J2V8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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