New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
app-crash after find and replace in a large file #14630
Comments
Have you tried it with plugins removed? |
No |
on another computer it took little over 10 minutes to complete the find and replace without crash. The crash on my computer is probably an issue on my machine, but it would be an improvement if the replacement could be a lot faster. debug info on the other computer |
As plugins are different on the two machines (and non-crashing machine has only the plugins that ship with Notepad++), it would be a valuable experiment to remove plugins from the crashing machine and see if crash repeats or not.
I wonder if Change History could be having an impact. Is it enabled? If so perhaps turn it off: Display Change History checkbox is in the Settings > Preferences > Margins/Border/Edge What are the find/replace text, and the search mode? |
another test on the crashing machine: |
What did you do to achive this? |
close another program |
I can confirm that this is a N++ issue, I tried:
Here are some free csv-files for testing: My N++ does not crash on them on my PC, but I had to terminate it from the task manager because it took too long to finish the replacement op. Display Change History feature has a negative influence but it is not the main culprit here. |
The crash in the initial report is likely memory exhaustion from undo data. A 32-bit version of Notepad++ is used so there is probably a limit of 2 or 3 GB of address space that can be used.
Thus, there are 10 million replaces with each being a deletion of a comma then an insertion of a semi-colon so 2 undo actions. A single basic 32-bit undo action is around 32 bytes so a total of around 640 MB is used which is a significant fraction of available address space. On top of that was the memory used for the change history feature. Windows Notepad implements undo differently and can only undo a single action although replace all is considered a single action. For this example, the 64-bit version of Notepad++ is less likely to run into memory problems.
Notepad++, unlike SciTE, leaves most notifications enabled so each replace operation will send 5 notifications [ Using document map or document peeker creates secondary views attached to the document and each notification is sent to each view, doubling or tripling the number of notifications. |
memory exhaustion is clear. |
I am not conversant with that part of the N++ code, but at first look it seems ok to me: notepad-plus-plus/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp Lines 3056 to 3066 in 50a6cf2
notepad-plus-plus/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp Lines 2659 to 2669 in 50a6cf2
@donho |
This PythonScript 3 script disables undo collection, emptys undo buffer and disables change history. from Npp import notepad
# Disable undo to prevent memory exhaustion.
if editor.getUndoCollection():
editor.setUndoCollection(False)
editor.setChangeHistory(0)
editor.emptyUndoBuffer()
notepad.messageBox('Undo is off')
else:
editor.setUndoCollection(True)
editor.setChangeHistory(3)
notepad.messageBox('Undo is on') Notepad++ memory (private working set) starts up at 77 MB with largest csv file loaded that @xomx provided. Not using the script: Still takes awhile to do the replacements though the memory saving is like no extra memory usage as it does not increase at all. |
If it is clear how a find and replace action can be greatly accelerated (not just twice. I prefer NPP, but I'm not going to wait for minutes if another program does it at least 10 times as fast). |
@nyamatongwe
By bulk ops do you mean undo & change history or the notifications? |
I mainly meant the notifications. For the change history feature might be enough a mention/switch in the N++ Preferences > Performance. And about the undo - if it will be possible not to do it for every single replace-op, but at once, that will also be great. |
Sounds good. |
Ok.
Maybe I did not use the right words.
For smaller files, let's say up to 500 KB, there is no need to worry about a limitation of that N++ rich notification functionality (in fact I have no idea if that rich notification functionality is really needed or what exactly will happen if we temporarily limit that, as I did not write / study relevant N++ code parts). But for larger files, for such multirepetitive ops, they should be at least temporarily disabled if possible.
Ok.
If you could, please assign yourself to this. Unfortunately I am short of time, I am not even able to finish my coding for other N++ issues, sorry about that :-( |
Done some more testing with PythonScript using the same 26 MB CSV test file that xomx provided. from Npp import editor, notepad
# Disable undo to prevent memory exhaustion.
if editor.getUndoCollection():
editor.setUndoCollection(False)
editor.emptyUndoBuffer()
editor.setChangeHistory(0)
notepad.messageBox('Undo is off')
ModEventMask = editor.getModEventMask()
# SC_MOD_NONE = 0
editor.setModEventMask(0)
editor.setCommandEvents(False)
notepad.messageBox('Commands+EventMask is off')
else:
editor.setUndoCollection(True)
editor.setChangeHistory(3)
notepad.messageBox('Undo is on')
# Restore Mask (from getsetModEventMask 7FFFFF = SC_MODEVENTMASKALL)
editor.setModEventMask(ModEventMask)
editor.setCommandEvents(True)
notepad.messageBox('Commands+EventMask is on') Comment some code to get the variations.
|
So it is confirmed that the notifications are causing the biggest lag, right? |
@xomx Correct! Notifications (aka events in the table header) are causing the biggest lag in speed. Turning notifications off makes testing more differcult as it can finish quicker then I get to note the time from the systray so I had to be quick to check. What you quoted is what SciTE uses during Find and Replace which takes Disabling Undo for large files could be an option to disable though may make editing the files quite risky though memory use is |
@JeroenNienhuis |
where can I find the Windows build? |
https://github.com/notepad-plus-plus/notepad-plus-plus/actions/runs/7804509442 |
If I use the Win32 version without closing another program first, there is still an app crash (just like the current production version). The x64 behaves as expected. All items are replaces, also the second time. It is now much faster. |
@JeroenNienhuis Thank you for the confirmation. |
Description of the Issue
I have a csv file with over 500,000 lines (file size 50MB) and 20 comma's on each line. After a find and replace commas to semicolons NPP crashes after 5 minutes
(Windows notepad did the trick in 5 seconds)
Debug Information
Notepad++ v8.6.2 (32-bit)
Build time : Jan 14 2024 - 02:18:41
Path : C:\Program Files (x86)\Notepad++\notepad++.exe
Command Line : "D:\user\logins.txt"
Admin mode : ON
Local Conf mode : OFF
Cloud Config : OFF
OS Name : Windows 7 Professional (64-bit)
OS Build : 7601.0
Current ANSI codepage : 1252
Plugins :
ComparePlugin (2)
DSpellCheck (1.4.6)
JSMinNPP (1.1903)
mimeTools (3)
NppConverter (4.5)
NppExport (0.4)
NppTextFX (0.2.6)
PoorMansTSqlFormatterNppPlugin (1.6.10.1279)
XMLTools (2.4.11)
The text was updated successfully, but these errors were encountered: