rizonesoft / Notepad3

Notepad like text editor based on the Scintilla source code. Notepad3 based on code from Notepad2 and MiniPath on code from metapath. Download Notepad3:
https://www.rizonesoft.com/downloads/notepad3/
Other
5.12k stars 337 forks source link

Memory usage compared with Notepad2-mod #2687

Closed dlong500 closed 4 years ago

dlong500 commented 4 years ago

I'm seeing anywhere from 3-8 times the memory usage with Notepad3 compared to Notepad2-mod since I recently started using Notepad3. Here's a couple very quick reference points: when just opening up the applications with blank files Notepad2-mod is around 3.2MB, while Notepad3 is around 8.5MB. If I open up an 8MB text file Notepad2-mod is using around 22MB, while Notepad3 is using 158MB.

There maybe some perfectly reasonable explanations for the large difference in memory usage, but I didn't find any discussions on the matter. I'm more curious as to why there would be such a big difference since Notepad3 is based on Notepad2/Notepad2-mod. Does anyone have some insight?

It may not even seem like much of a concern given how much memory most devices have these days, but I regularly work on dozens of large files at a time, so it's easy to get up into the GBs of memory usage.

RaiKoHoff commented 4 years ago

Hello @dlong500,

you are right, adding new features will increase the memory footprint of any tool. For Notepad3, there are additional bigger toolbar button bitmaps, high-resolution icons, new and extended(Scintilla) statically linked libraries (Oniguruma-RegEx-Engine, UCHARDET encoding detection lib, MUI language handling, new .ini-file handler, new source code, more large static buffers (memory allocation speed), etc.).

Dynamic memory usage on runtime increased too. Beside lots of minor stuff (new (modern) dynamic link libs (DLL), keeping undo/redo history of selection, etc.), the biggest memory consumption on loading text files is: Notepad3 uses always UTF-8 internal encoding (document space), which blows up the memory consumption by 3x or 4x times, even if you only use ASCII text. This makes a lot of internal handling easier (see Flo's Notepad2 original v5 changelog (not published source code). Another big dynamic memory eater can be keeping the complete (modified) text in undo-history while reverting the file from disc (see issue 1089).

If you really need to focus on memory footprint, try Zufuliu's Notepad2-mod fork, which is also on up-to-date development state (Scintilla, bug-fixes, new features). This fork keeps the smaller internal encoding based on optimal code-page and focused more on memory foot-print.

dlong500 commented 4 years ago

@RaiKoHoff Thanks for the info, and especially for the link to the specific Notepad2-mod fork. That's definitely a good fallback option to have if there are memory issues. I wish Github had a better way of letting people know when there are actively maintained forks for various projects. The forks page and network graph don't really show how active a particular fork may or may not be.

I haven't even had problems with the older Notepad2-mod as of yet, but it's always good to try something new on occasion and it's nice to know a project is being maintained in case an OS update happens to cause a problem.

RaiKoHoff commented 4 years ago

@dlong500 : You are welcome. There must not only be one Highlander - correction: Notepad ;-)