<blockquote>
<p>This already happens:</p>
<ul>
<li>
<p><a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/a8a1dc1e33267e0fa2dab22959e41d0a072420d9/platforms/iOS/vm/Common/main.m#L59">opensmalltalk-vm/platforms/iOS/vm/Common/main.m</a></p>
<pre><code>     Line 59
  in
  [a8a1dc1](/OpenSmalltalk/opensmalltalk-vm/commit/a8a1dc1e33267e0fa2dab22959e41d0a072420d9)





    
      
       @autoreleasepool {
</code></pre>
</li>
<li>
<p><a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/a8a1dc1e33267e0fa2dab22959e41d0a072420d9/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication.m#L154">opensmalltalk-vm/platforms/iOS/vm/Common/Classes/sqSqueakMainApplication.m</a></p>
<pre><code>     Line 154
  in
  [a8a1dc1](/OpenSmalltalk/opensmalltalk-vm/commit/a8a1dc1e33267e0fa2dab22959e41d0a072420d9)





    
      
       @autoreleasepool {
</code></pre>
</li>
</ul>
<p>But I think this is not enough. If I understand ARC correctly, <em>leaving</em> 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…</p>
<p>(<a class="user-mention" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=972602" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/johnmci">@johnmci</a> please correct me if I'm wrong)</p>
</blockquote>
<p>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.</p>
<p>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.</p>
<p>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.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you commented.<br />Reply to this email directly, <a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/374#issuecomment-472535029">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AhLyW7Hc1ALcz0yyCBkeY0bAlo39wAa-ks5vWTrWgaJpZM4bXsAc">mute the thread</a>.<img src="https://github.com/notifications/beacon/AhLyWzvbHx5ZzmE0woXk0u9UUG5ZSZc9ks5vWTrWgaJpZM4bXsAc.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/OpenSmalltalk/opensmalltalk-vm","title":"OpenSmalltalk/opensmalltalk-vm","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/OpenSmalltalk/opensmalltalk-vm"}},"updates":{"snippets":[{"icon":"PERSON","message":"@johnmci in #374: \u003e This already happens:\r\n\u003e \r\n\u003e * [opensmalltalk-vm/platforms/iOS/vm/Common/main.m](https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/a8a1dc1e33267e0fa2dab22959e41d0a072420d9/platforms/iOS/vm/Common/main.m#L59)\r\n\u003e       \r\n\u003e       \r\n\u003e            Line 59\r\n\u003e         in\r\n\u003e         [a8a1dc1](/OpenSmalltalk/opensmalltalk-vm/commit/a8a1dc1e33267e0fa2dab22959e41d0a072420d9)\r\n\u003e       \r\n\u003e       \r\n\u003e       \r\n\u003e       \r\n\u003e   \r\n\u003e           \r\n\u003e             \r\n\u003e              @autoreleasepool {\r\n\u003e * [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)\r\n\u003e       \r\n\u003e       \r\n\u003e            Line 154\r\n\u003e         in\r\n\u003e         [a8a1dc1](/OpenSmalltalk/opensmalltalk-vm/commit/a8a1dc1e33267e0fa2dab22959e41d0a072420d9)\r\n\u003e       \r\n\u003e       \r\n\u003e       \r\n\u003e       \r\n\u003e   \r\n\u003e           \r\n\u003e             \r\n\u003e              @autoreleasepool {\r\n\u003e \r\n\u003e 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…\r\n\u003e \r\n\u003e (@johnmci please correct me if I'm wrong)\r\n\r\nIn 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.  \r\n\r\nIn 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.\r\n\r\nWe 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. \r\n"}],"action":{"name":"View Issue","url":"https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/374#issuecomment-472535029"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/374#issuecomment-472535029",
"url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/374#issuecomment-472535029",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>