Hi Dave,
This is cool :) I'd like to ask you a few questions if you don't mind:
1. I can't see any implementor of #freeSomeSpace (and it wasn't there even before your changes) - why's that?
2. I can't see any senders of #registerCleaner: - does it mean the system doesn't use this or what am I missing?
3. If I'm not mistaken the condition in #safeToInstall is equivalent to:
safeToInstall "Free space must be above threshold before starting low space watcher"
^SmalltalkgarbageCollectMost>SmalltalklowSpaceThreshold or:[SmalltalkgarbageCollect>SmalltalklowSpaceThreshold]
- which is (at least to me) a bit better decipherable.
4. I've noticed you replaced `LowSpaceWatcher install` with `LowSpaceWatcher default start` in #lowSpaceWatcher - nice, no need to terminate explicitly; I just wonder why to nil the lowSpaceProcess variable in #disableVirtualMachineNotifications.
Thanks a lot, it's a joy to read the refactored code :)
best -- Jaromir
On 2024-02-01 23:54, Jaromir Matas wrote:
Hi Dave,
This is cool :) I'd like to ask you a few questions if you don't mind:
- I can't see any implementor of #freeSomeSpace (and it wasn't there
even before your changes) - why's that?
Well spotted :-)
If you look at the method stamp for #memoryHogs you can see that the MemoryHogs idea was introduced back in 2000 by Stefan Matthias Aust (sma). The idea (based on my reading of the code) was that certain objects or classes might use a lot of memory (possibly for caching or similar purposes) and that if you asked them nicely to free up some memory (#freeSomeSpace) they would know how to do so.
There are currently no implementers of #freeSomeSpace, and it seems quite likely that either this is a good idea that has been forgotten, or that it simply did not prove to be very useful in practice.
If this a good idea, should we start using it? Or should the MemoryHogs mechanism be removed? I really don't know.
If we think that it is a good idea, then we might consider implementing things like this:
McFileBasedRepository class>>freeSomeSpace ^self flushAllCaches
- I can't see any senders of #registerCleaner: - does it mean the
system doesn't use this or what am I missing?
This is the same issue as #1 above. I added the method only because the MemoryHogs registry exists. It is empty and unused now, but if someone were to implement #freeSomeSpace, then they probably would want to be able to add their class to the registry.
- If I'm not mistaken the condition in #safeToInstall is equivalent
to:
safeToInstall "Free space must be above threshold before starting low space watcher"
^Smalltalk garbageCollectMost > Smalltalk lowSpaceThreshold or: [Smalltalk garbageCollect > Smalltalk lowSpaceThreshold]
which is (at least to me) a bit better decipherable.
Yes, your version above is better and easier to understand.
And just to double check our (my) logic, the original section of code in the #lowSpaceWatcher method looked like this:
self garbageCollectMost <= self lowSpaceThreshold ifTrue: [self garbageCollect <= self lowSpaceThreshold ifTrue: ["free space must be above threshold before starting low space watcher" ^ Beeper beep]].
Dave
Hi Dave,
On 02-Feb-24 1:45:06 AM, lewis@mail.msen.com wrote:
On 2024-02-01 23:54, Jaromir Matas wrote:
Hi Dave,
This is cool :) I'd like to ask you a few questions if you don't mind:
- I can't see any implementor of #freeSomeSpace (and it wasn't there even before your changes) - why's that?
Well spotted :-)
If you look at the method stamp for #memoryHogs you can see that the MemoryHogs idea was introduced back in 2000 by Stefan Matthias Aust (sma). The idea (based on my reading of the code) was that certain objects or classes might use a lot of memory (possibly for caching or similar purposes) and that if you asked them nicely to free up some memory (#freeSomeSpace) they would know how to do so.
There are currently no implementers of #freeSomeSpace, and it seems quite likely that either this is a good idea that has been forgotten, or that it simply did not prove to be very useful in practice.
If this a good idea, should we start using it? Or should the MemoryHogs mechanism be removed? I really don't know.
If we think that it is a good idea, then we might consider implementing things like this:
MCFileBasedRepository class>>freeSomeSpace ^self flushAllCaches
- I can't see any senders of #registerCleaner: - does it mean the system doesn't use this or what am I missing?
This is the same issue as #1 above. I added the method only because the MemoryHogs registry exists. It is empty and unused now, but if someone were to implement #freeSomeSpace, then they probably would want to be able to add their class to the registry.
Thanks a lot for your explanation! It'd be great for anyone seeing this code for the first time to see your explanation; however, I wonder what would be an appropriate place for this kind of remarks. (My suggestion in another thread were special class documentation methods that would capture this sort of "extended" comments until some better tool/idea is available.)
Do you think complementing the #registerCleaner: with something like ``` deregisterCleaner:memoryCleaner "Remove memoryCleaner from the MemoryHog list."
selfdefaultmemoryHogsremove:memoryCleanerifAbsent:[] ``` would make sense?
Thanks again; I guess now I finally understand this piece of code.
best, Jaromir
- If I'm not mistaken the condition in #safeToInstall is equivalent to:
safeToInstall "Free space must be above threshold before starting low space watcher"
^Smalltalk garbageCollectMost > Smalltalk lowSpaceThreshold or: [Smalltalk garbageCollect > Smalltalk lowSpaceThreshold]
which is (at least to me) a bit better decipherable.
Yes, your version above is better and easier to understand.
And just to double check our (my) logic, the original section of code in the #lowSpaceWatcher method looked like this:
self garbageCollectMost <= self lowSpaceThreshold ifTrue: [self garbageCollect <= self lowSpaceThreshold ifTrue: ["free space must be above threshold before starting low space watcher" ^ Beeper beep]].
Dave
On 2024-02-03, at 11:32 AM, Jaromir Matas mail@jaromir.net wrote:
It'd be great for anyone seeing this code for the first time to see your explanation; however, I wonder what would be an appropriate place for this kind of remarks. (My suggestion in another thread were special class documentation methods that would capture this sort of "extended" comments until some better tool/idea is available.)
Don't forget that method comments can include links to class comments etc. This can be a useful way to point readers from a method (or ten) to the same bit of more extensive doc.
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Strange OpCodes: RDLI: Rotate Disk Left Immediate
On 2024-02-03 20:54, Tim Rowledge wrote:
On 2024-02-03, at 11:32 AM, Jaromir Matas mail@jaromir.net wrote:
It'd be great for anyone seeing this code for the first time to see your explanation; however, I wonder what would be an appropriate place for this kind of remarks. (My suggestion in another thread were special class documentation methods that would capture this sort of "extended" comments until some better tool/idea is available.)
Don't forget that method comments can include links to class comments etc. This can be a useful way to point readers from a method (or ten) to the same bit of more extensive doc.
Indeed, I am surprised that the hyperlinking has not gotten more use in our comments. It seems like a really nice way to tie things together within the image. But I also find myself forgetting about it when I am actually writing a comment, and when I do want to use it I always forget what magic keystrokes to use to make a link. Maybe we just need some way to make the "turn this text into a link" mechanism easier to find and use.
Dave
Yeah - seems like something that ought to be integrated into the set font/set style/ set alignment world in the text menu(s). Cmd-6 is all very well if you use it frequently but I rather suspect many people have no idea about the assorted cmd-numeral stuff.
On 2024-02-03, at 3:18 PM, lewis@mail.msen.com wrote:
On 2024-02-03 20:54, Tim Rowledge wrote:
On 2024-02-03, at 11:32 AM, Jaromir Matas mail@jaromir.net wrote: It'd be great for anyone seeing this code for the first time to see your explanation; however, I wonder what would be an appropriate place for this kind of remarks. (My suggestion in another thread were special class documentation methods that would capture this sort of "extended" comments until some better tool/idea is available.)
Don't forget that method comments can include links to class comments etc. This can be a useful way to point readers from a method (or ten) to the same bit of more extensive doc.
Indeed, I am surprised that the hyperlinking has not gotten more use in our comments. It seems like a really nice way to tie things together within the image. But I also find myself forgetting about it when I am actually writing a comment, and when I do want to use it I always forget what magic keystrokes to use to make a link. Maybe we just need some way to make the "turn this text into a link" mechanism easier to find and use.
Dave
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Useful random insult:- If his IQ was two points higher he'd be a rock.
Indeed. And as soon as you said that, I tried highlighting some text in a comment to see where it might belong in the right-click menu. There is an entire menu section that would be perfect, currently it contains only "make project link (P)". I'm not sure what a project link is good for, but never mind that at least it works :) So adding something like "make comment link" or "make documentation link" might be a good fit. A "remove link" menu entry might be helpful as well.
And to confirm your suspicion - I have no clue what any of the cmd-numeral stuff is and I would never think to go looking for it.
Dave
On 2024-02-03 23:26, Tim Rowledge wrote:
Yeah - seems like something that ought to be integrated into the set font/set style/ set alignment world in the text menu(s). Cmd-6 is all very well if you use it frequently but I rather suspect many people have no idea about the assorted cmd-numeral stuff.
On 2024-02-03, at 3:18 PM, lewis@mail.msen.com wrote:
On 2024-02-03 20:54, Tim Rowledge wrote:
On 2024-02-03, at 11:32 AM, Jaromir Matas mail@jaromir.net wrote: It'd be great for anyone seeing this code for the first time to see your explanation; however, I wonder what would be an appropriate place for this kind of remarks. (My suggestion in another thread were special class documentation methods that would capture this sort of "extended" comments until some better tool/idea is available.) Don't forget that method comments can include links to class comments etc. This can be a useful way to point readers from a method (or ten) to the same bit of more extensive doc.
Indeed, I am surprised that the hyperlinking has not gotten more use in our comments. It seems like a really nice way to tie things together within the image. But I also find myself forgetting about it when I am actually writing a comment, and when I do want to use it I always forget what magic keystrokes to use to make a link. Maybe we just need some way to make the "turn this text into a link" mechanism easier to find and use.
Dave
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Useful random insult:- If his IQ was two points higher he'd be a rock.
Hi Jaromir,
On 2024-02-03 19:32, Jaromir Matas wrote:
Hi Dave,
On 02-Feb-24 1:45:06 AM, lewis@mail.msen.com wrote:
On 2024-02-01 23:54, Jaromir Matas wrote:
- I can't see any senders of #registerCleaner: - does it mean the
system doesn't use this or what am I missing?
This is the same issue as #1 above. I added the method only because the MemoryHogs registry exists. It is empty and unused now, but if someone were to implement #freeSomeSpace, then they probably would want to be able to add their class to the registry.
Thanks a lot for your explanation! It'd be great for anyone seeing this code for the first time to see your explanation; however, I wonder what would be an appropriate place for this kind of remarks. (My suggestion in another thread were special class documentation methods that would capture this sort of "extended" comments until some better tool/idea is available.)
Do you think complementing the #registerCleaner: with something like ``` deregisterCleaner: memoryCleaner _"Remove memoryCleaner from the MemoryHog list."_
self default memoryHogs remove: memoryCleaner ifAbsent: [] ``` would make sense?
I think it makes sense, but it would be better to save the question for later. Why? I added #registerCleaner for purposes of documentation, not because it is really needed from an implementation point of view. It calls your attention to the MemoryHogs registry and provides a convenient place for a method comment and some error checking. Aside from that, it serves no functional purpose because there is already a #memoryHogs accessor method elsewhere.
We might decide in the future to add #deregisterCleaner, but for now it is better to stop and think about whether we are fixing the right problem. Now that we have noticed that the registry exists, we should also notice that nobody has used it for the last 20 years or so. So before we make it easier to use the registry, we should ask ourselves why we are using it in the first place. If it serves no useful purpose, then we can deprecate it and not worry about further improvements :-)
Dave
squeak-dev@lists.squeakfoundation.org