5 ms·
It's surprisingly hard to find if a given memory address is free or used... After all, it might have been freed in the application memory allocator, but stil
by londons_explore 6y ago
It's surprisingly hard to find if a given memory address is free or used... After all, it might have been freed in the application memory allocator, but still part of an allocation pool... Or the allocation pool has been freed, but not returned to the kernel via MADV_DONTNEED. etc.
Besides, if one is making a copy of a big (ie. greater than a page) piece of data to make modifications, one probably should have used some kind of data structure that deduplicated the parts of the data which weren't modified - that saves the unmodified parts of the data needing to even be read/written by the CPU.
- Andys 6y agoI'm thinking of low-level programming. Generally, operations on strings don't modify them in place, they are copied each time, and the old memory free()'d or garbage collected, which wouldn't bother clearing the memory.