[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] callout from interp.c code to objc/swift code need autorelease pool (#374)

johnmci notifications at github.com
Wed Mar 13 17:52:22 UTC 2019


> This already happens:
> 
> * [opensmalltalk-vm/platforms/iOS/vm/Common/main.m](https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/a8a1dc1e33267e0fa2dab22959e41d0a072420d9/platforms/iOS/vm/Common/main.m#L59)
>       
>       
>            Line 59
>         in
>         [a8a1dc1](/OpenSmalltalk/opensmalltalk-vm/commit/a8a1dc1e33267e0fa2dab22959e41d0a072420d9)
>       
>       
>       
>       
>   
>           
>             
>              @autoreleasepool {
> * [opensmalltalk-vm/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication.m](https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/a8a1dc1e33267e0fa2dab22959e41d0a072420d9/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication.m#L154)
>       
>       
>            Line 154
>         in
>         [a8a1dc1](/OpenSmalltalk/opensmalltalk-vm/commit/a8a1dc1e33267e0fa2dab22959e41d0a072420d9)
>       
>       
>       
>       
>   
>           
>             
>              @autoreleasepool {
> 
> But I think this is not enough. If I understand ARC correctly, _leaving_ the autoreleasepool-ed region triggeres the cleanup etc. Hence, this would would only trigger after the respecive code leaves. Which is, not during normal operation…
> 
> (@johnmci please correct me if I'm wrong)

In these cases the called routine only terminates when Squeak terminates. It's a programming style pattern, but doesn't of course cleanup memory as the interpreter is running.  

In some variations of the VM (like for a browser plugin) we wrote the code so that after N byte codes interpreted, we would save the state, and exit the interpreter loop, and return back to the caller. Later the caller would call back into the interp.c and resume.  At that point we could unwind the autorelease pool. However I don't recommend that as a solution due to overhead.

We have tools to check for memory leaking, just need to run them from time to time to ensure a os-x or iOS platform change hasn't introduced a leak by forgetting a auto-release pool. 


-- 
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/374#issuecomment-472535029
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20190313/724c9d00/attachment.html>


More information about the Vm-dev mailing list