With large files and many replaces an out of memory error can happen.
Store some of the information on disk instead of memory.
Stop search and replace a while before out of memory is reached and ask what to do (choice-dialog):
- save changes to disk and empty undo cache
- just stop search&replace
- undo all changes made by search and replace so far
Generally, option to save to disk while discarding undo when memory gets low. Disk-swapping for 32bit system (temporary file), check max size of temp file for 64-bit edition, else also implement disk-swapping.