Along the lines of Nicolas' hint, here's one example of what you can *not*
do, and expect to work (just the other way around):

GLMPagerScrollBrick pagerModel: aModel
    pagerModel := aModel.
    -snip-
    pagerModel announcer weak
        when: GLMPagePushed send: #onPagePushed: to: self.
    -snip-

In a workspace:
pager:= GLMPagerModel new.
brick := GLMPagerScrollBrick  new.
brick pagerModel: pager.
brick := nil.
Smalltalk garbageCollect.
pager announcer subscriptions numberOfSubscriptions. --> 8

And, with a small addition of early exit after nilling pagerModel if aModel
is nil:
(pager announcer subscriptions instVarNamed: #subscriptions) anyOne
subscriber pagerModel: nil.
Smalltalk garbageCollect.
pager announcer subscriptions numberOfSubscriptions. --> 0

In other words: You can NOT hold references to Announcers in an object that
subscribes to it weakly.

Cheers,
Henry



--
View this message in context: 
http://forum.world.st/Some-Memory-Leak-tp4814779p4814906.html
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.

Reply via email to