-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Autoreleasepools with Metal #103
Comments
come cryptic notes for my future self: There are two places where Metal.jl is currently leaking due to no autorelease pools:
More broadly: |
Having libuv manage the first level of autorelease pool feels like the right solution. We could wrap the following https://github.com/JuliaLang/libuv/blob/fa7058b865e3c4a5a9c9ff511ed3e589ce817a85/src/unix/core.c#L386-L441 in a GTK's solution: GLFW's trick to get menu's etc to show properly: call On my todo list: understand a little better the current on multithreading and libuv |
From the metal-cpp docs:
|
Objective-C methods in the
Metal.framework
should be executed within Autorelease Pools. This is also true for most other Cocoa frameworks, and not invoking methods within Autorelease pools leads to leaked memory.todo: Make sure there is consensus on this conclusion / provide a compelling and concise argument if there are doubts.
We can easily expose autoreleasepools in libcmt with a single new function e.g.:
MtAutoreleasePool* mtNewAutoreleasePool() {return [[NSAutoreleasePool alloc] init];}
Weeds:
@autoreleasepool
blocks instead)libcmt
is currently compiled witharc
off (the default)target_compile_options(cmt PRIVATE -fno-objc-arc)
Autorelease Pools are useful in macos/ios world and care should be taken not to hide them from the end user. With that said, they probably need to be auto-inserted by Metal.jl in the array programming interface, and also maybe in
@Metal.sync
Autorelease Pools do have some complications:
CUDA.jl
and probably make addingMetal.jl
support toKernalAbstractions.jl
more challengingThe text was updated successfully, but these errors were encountered: