5 ms·
No, it was actually in a (obscure scientific) garbage collected language. The syntax was roughly: `allOrbitFiles = allOrbitFiles + currentOrbitFiles`. I believ
by morcus 3y ago
No, it was actually in a (obscure scientific) garbage collected language. The syntax was roughly:
`allOrbitFiles = allOrbitFiles + currentOrbitFiles`.
I believe what was roughly happening under the hood was:
1. Allocate an array `tmp` of size `length of allOrbitFiles` + `length of currentOrbitFiles`.
2. Copy data from `allOrbitFiles` over to `tmp`.
3. Copy data from `currentOrbitFiles` to `tmp`
4. Reassign `allOrbitFiles` to the new array `tmp`.
5. Garbage collect the old `allOrbitFiles`.
So the doubling of memory usage comes after Step 1. I would imagine (but don't know for sure) that this would actually occur in any garbage collected language I'm familiar with as well (Java, Python, Javascript).
- ericmcer 3y agoYes it would happen in JS/python/etc as well once (2 * allOrbitFiles) > Memory. Cool fix I never think about my arrays being larger than memory haha.