Skip to content

Conversation

@pjkaufman
Copy link
Collaborator

Relates to #1268

An issue was reported where the Linter would cause Obsidian to freeze on a large file. I thought it would be like the others where it froze because the Linter was long running. And while that is partially the cause, I encountered an issue where Obsidian would crash on me due to high RAM usage (an OOM error). After debugging the process and trying to figure out what was going on, I was able to determine that using substring on a string was creating a pointer to it. So I was accidentally keeping around many references to the original copy of the string I was then updating in the ignore types logic. This meant that since the file in question was about .9MB, I was getting this file's size roughly duplicated for each value replaced. In the file, it was more than 300 times. To fix this, it is best to first get all of the substrings and then update the string. This way we only keep one extra instance of the text present. This drastically reduced the RAM usage.

I also added some logic to limit the amount of characters from a file that can be logged to also help keep RAM usage low.

Changes Made:

  • Capped file content character size to keep in the logs for each rule that runs
  • Updated the ignore types logic to make sure that it would not unnecessarily retain copies of strings it did not need to keep around (yay hidden pointers!)

@pjkaufman pjkaufman self-assigned this May 13, 2025
@pjkaufman pjkaufman added the bug Something isn't working label May 13, 2025
@pjkaufman pjkaufman merged commit 223be97 into platers:master May 13, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant