3 ms·
With an application using garbage collection it's quite easy to have hundreds of megabytes just sitting around, so I think it could be a good idea in some cases
by joshhart 14y ago
With an application using garbage collection it's quite easy to have hundreds of megabytes just sitting around, so I think it could be a good idea in some cases.
- cbhl 14y agoPerhaps, but an application using garbage collection will likely have malloc abstracted away from the developer.
- anders0 14y agoBut couldn't the language's runtime (or the GC library, or whatever) register for these notifications?
- cbhl 14y agoYes, but my impression is that the set of conditions where this helps (you have memory pressure AND the runtime has lots of memory it can free up) is rather rare. If you have memory pressure, that's usually the same time that the runtime is actually trying to make use of lots of memory. IIRC, Android provides something along these lines (as does Windows Phone 7.1), and when you get under memory pressure (common on Honeycomb-based tablets) you end up with thousands of these notifications, each freeing up 1KB or 2KB when you really need to free up tens of megabytes (which you can only do by serializing and terminating an application).
- munin 14y agoaha! true, yes. I hadn't considered that case. then it would make sense. I suppose another case would be if you were maintaining some kind of data cache that could either be discarded or flushed to disk. so maybe these mechanisms are more useful than I thought.