3 ms·
I guess there is something I am missing here. The original code should consume not much more memory than the optimized one. Yes you're going to allocate a lot
by mrighele 3y ago
I guess there is something I am missing here.
The original code should consume not much more memory than the optimized one. Yes you're going to allocate a lot of more memory, but whatever doesn't finish in the record becomes garbage after every single line, so I can expect worse performance, but not using two order of magnitude more memory.
I would see more problematic the fact that you're collecting all the records in a single array. Depending on how you use them it can be beneficial to use a generator and consume them incrementally.
- didntcheck 3y agoAgreed in terms of live memory, but if it's purely measuring heap size then it makes more sense. So it possibly could run with a much stricter memory limit, but with the tradeoff of more GC (and for a compacting GC, this would mean lower throughout, since the GC time is proportional only to live objects. May as well let the garbage pile up as much as you can and therefore do fewer collections)