Thursday, October 6, 2011

GemKit and Atomic Loading

In VisualWorks 7.8, I have to turn off atomic loading in order to load the package GbcManagement. If I didn't, the load crashed with a memory overflow.

After tracing down the problem, I found that the load itself actually worked fine.  It was the step right afterward that did a purgeUnusedBindings that was failing - specifically in a method called relinkSystem.  The relinkSystem method looped through allInstances of DeferredBinding.  Maybe it was hitting an object that was garbage but hadn't yet been garbage collected.  So, I added a call to do a garbage collect just before the allInstances.  That did the trick.  GbcManagement loads perfectly every time now.

It goes to show that you have to be careful with allInstances.

1 comment:

  1. The deeper cause of that is related to a VW delay in finalizing weak references. The #quickGC method does the trick faster. Nice workaround, but the cursor changes in #doOrFinishIncrementalGC can cause problems non-UI processes that would relink. A workaround I use for that (in other code) is to implement and send a #quickGC_quietly method that calls a #doOrFinishIncrementalGC_quietly that doesn't have the cursor code.

    ReplyDelete