2 ms·
My issue is that with GC-able languages, people don't seem to care as much with allocating lots of data and expecting the GC to wipe it all away. To give a rec
by Jasper_ 11y ago
My issue is that with GC-able languages, people don't seem to care as much with allocating lots of data and expecting the GC to wipe it all away.
To give a recent example, HTML5's canvas API only allows accessing image data with getImageData, which will allocate a large array for you, and then return it. You cannot do this at 60fps, because of GC pauses (and also because Chrome doesn't actually track the memory usage of the ImageData correctly, leading it to run out of memory rather than correctly free the object).
There is no way to pass in a pre-allocated buffer, because the presumed cost of the GC is free. When developers are asked to track memory usage themselves, they're allowed to be a lot more careful with it, and design APIs that take that cost into account.