I FOUND IT.
The bug is due to windows superfetch. You have to disable it completely within the registry. Google how to until i get time to write a guide
Edit: Superfetch is a windows service that tries to speculate on what programs you're likely to use, and prefetches the data so it's "ready". It's *, especially in windows 10 with an SSD. And it causes all sorts of issues. I found the culprit by checking the windows event viewer and analyzing wtf those perflib and perfNet errors were. It's the performance monitor. It was coming up with all sorts of warnings and errors. One of the recuring bug being
"Windows cannot load the extensible counter DLL "C:\Windows\system32\sysmain.dll" (Win32 error code The specified module could not be found.)."
sysmain is the name of superfetch in windows 10.
I also disabled a lot of automated crap in task manager, such as hourly microsoft office updates and other forced crap like that.
Since then, when I get the "lag spikes" or freezes where I know it's going to crash. Well, I don't crash. It just lag spikes then goes away.
Edit: Here's a quick copy pasta of how to disable superfetch:
Disable from Services
- Hold the Windows Key, while pressing “R” to bring up the Run dialog box.
- Type “services.msc“, then press “Enter“.
- The Services window displays. Find “Superfetch” in the list.
- Right-click “Superfetch“, then select “Properties“.
- Select the “Stop” button if you wish to stop the service. In the “Startup type” dropdown menu, choose “Disabled“.
Enable or Disable from Registry
- Hold the Windows Key, while pressing “R” to bring up the Run dialog box.
- Type “Regedit“, then press “Enter“.
- The Registry Editor window appears. Navigate to the following location in the Registry.
- HKEY_LOCAL_MACHINE
- SYSTEM
- CurrentControlSet
- Control
- Session Manager
- MemoryManagement
- PrefetchParameters
- On the right side, double-click on “EnableSuperfetch“. If this value doesn’t exist, right-click the “PrefetchParameters” folder, then choose “New” > “DWORD Value“.
- Give “EnableSuperfetch” one of the following values:
- 0 – to disable Superfetch
- 1 – to enable prefetching when program is launched
- 2 – to enable boot prefetching
- 3 – to enable prefectching of everything
- Select “OK“.
- Close the Registry Editor.
Note: If you disable Superfetch and would like to enable it for certain applications, you can use special switch in the program shortcut: /prefetch:1