I found the following list threads...
http://forum.world.st/Finalization-question-td1300962.html mentions #beFinalizable, which doesn't seem to exist. I guess it was just an example, but seems like it should be added, no?
In
http://forum.world.st/object-finalization-td3771196.html Igor suggested that the key is to do:
WeakRegistry default add: obj.
This guarantees? that #finalize will be called when the object is garbage collected.
I'm asking regarding my recent work wrapping the FMOD sound library with NativeBoost. I'm thinking my NBExternalObjects should release their resources when no longer referenced. I want to say:
FmodSound>>#finalize
self primReleaseSound: handle.
So I've pieced together that I would have to also write:
FmodSound>>new
instance := super new
whatever;
beFinalizable;
yourself.
Object>>#beFinalizable
WeakRegistry default add: self.
Am I correct that:
1. The above code would cause the resource to be safely released when the sound object was garbage collected?
2. This approach would be a good way to manage these types of resources?
Any hints would be appreciated as to the best way to accomplish managing these...
Thanks!
Cheers,
Sean