3 ms·
It would require runtime overhead over C/C++ to check whether every pointer is really is in static or heap memory every time you want to free it.
by pcwalton 13y ago
It would require runtime overhead over C/C++ to check whether every pointer is really is in static or heap memory every time you want to free it.
- acqq 13y agoAs far as I understand, the effective overhead of "free" can be practically zero if the compile-time construction of the static strings would contain some "nothing to deallocate here" info versus any info which anyway has to be run-time maintained to anything that is really allocated. Any non-trivial allocator has a bunch of checks to do (e.g. different-sized small objects are typically allocated in separate blocks, differently to the big allocations etc). As soon as your language doesn't use C-like zero-terminated characters but anything with more information, it's trivial to avoid these unnecessary copy-to-heap-just-to-use-and-deallocate steps.