On 6 Apr 2014, at 11:01, Peter Kim wrote:
- Memory usage should be in the ballpark of starting footprint (40
MB) + file (66 MB) = 106 MB.
This is not possible because TM associates scopes with everything in your document and it also needs to create CoreText line objects to render the text (which is too slow to do ad-hoc so these are cached).
It will probably need 10-20 extra bytes per character in your document, which turns 66 MB into ~1 GB, add in memory fragmentation and data structure alignment requirements, and you probably have your 1.4 GB.
Maybe it can be improved, maybe there is the need for a special (limited) mode for large files, but it’s not currently a priority.
- After closing the window/file, memory footprint should go back to
near starting footprint (40 MB)
How do you measure this? The malloc allocator does not give pages back to the OS (AFAIK), so once a process has increased its number of allocated pages, the count does not go down again.
- Closing and reopening a file should not increase memory footprint
further.
This might be due to fragmentation. Here one solution could be a custom memory allocator to keep everything related to a document allocated from the same memory pool, but there are still many other things I would like to do, before I look into such optimizations.