Kernel Mode Heap Corruption on Windows and How to Fix It
Your game freezes halfway through a match. Windows flashes a stop code, the PC restarts, and you’re back at the desktop before you’ve had time to read the whole message. You load the game again. Ten minutes later, the same thing happens.
That second crash gives you something to work with. If the screen says KERNEL_MODE_HEAP_CORRUPTION, take a photo or write down the code. Think back to when the trouble started. A graphics driver installed last night or new RAM fitted over the weekend can give you a place to start. And if Windows still lets you sign in, back up the files you’d hate to lose while you have the chance.
Table of Contents
- What the 0x13A stop code means
- Check what changed before the first crash
- Boot into Safe Mode if Windows keeps restarting
- Roll Back or Update the Driver Causing the Crash
- Test your RAM if the crashes seem random
- Repair Windows files if other features are failing
- Read the crash dump if the problem keeps coming back
What the 0x13A stop code means
A heap is a pool of memory that code can use in chunks as it needs them. Windows tracks which chunks are in use and which are available again. Some heaps serve code running in kernel mode, where the core of Windows and many device drivers operate. The kernel mode heap corruption stop code means Windows found damage in one of those heaps. On Windows 10 and 11, Microsoft documents it as bug check 0x0000013A, often shortened to 0x13A.
Picture a driver reserving space for 100 bytes and then writing 104. The extra bytes could spill into the next block. Windows might only catch the damage later, when some other code needs that part of memory. That delay can make a crash look oddly timed. Windows might spot the problem when you close an app that was working fine a moment ago.
Check what changed before the first crash
Press Windows + R, type perfmon /rel, and press Enter to open Reliability Monitor. Pick the day the PC restarted and look at the failures alongside any installations it recorded. If an update might have arrived in the background, check Update history in Windows Update for its date. Even a rough timeline helps when several things changed in the same week.
Say the first crash came a day after you started using a USB-C dock. It seems to happen whenever the laptop wakes up. Shut down, disconnect the dock, and try a few sleep and wake cycles. If the laptop stays stable, check the dock maker’s support page for driver or firmware updates for that model. Seeing the crash return when you reconnect the dock makes the link more convincing.
A single crash deserves a note. If the PC has been fine ever since, carry on and see how it behaves. You’ll have the date and stop code handy if it comes back.
Boot into Safe Mode if Windows keeps restarting
If you can reach the sign-in screen, hold Shift while selecting Power > Restart. Windows can also enter its recovery environment automatically after repeated startup failures. Once you’re there, choose Troubleshoot > Advanced options > Startup Settings > Restart, then press 4 or F4 for Safe Mode. Windows may ask for the BitLocker recovery key if your device is encrypted.
Safe Mode loads a basic set of drivers and services. Suppose normal startup crashes as soon as you sign in, and Safe Mode lets you sit at the desktop. That’s a good reason to investigate a driver or app you recently added. A crash that usually takes an hour of gaming is harder to reproduce in Safe Mode, where Windows loads fewer drivers.
If you have a restore point from before a troublesome installation, System Restore in the recovery menu’s Advanced options can get you back to it. Windows keeps your personal files and undoes system changes made after that point. That can affect apps, updates, or drivers you’ve installed since.
Roll Back or Update the Driver Causing the Crash
Start with a rollback if crashes began right after a graphics driver update. In Device Manager, expand Display adapters and right-click the GPU you want to check. Open Properties > Driver > Roll Back Driver. You’ll need administrator permissions. Restart and retry the activity that usually brings on the crash.
Sometimes the rollback button is grayed out. In that case, check the PC or GPU maker’s support page for a compatible earlier release. On a laptop, I’d start with the page for its exact model. If the driver is old and the crashes started without a recent update to undo, check Windows Update or the manufacturer’s site for a newer supported version.
Give each change a fair test. If the PC usually crashes when you export a ten-minute video, run the same project with the same export settings. When you change several things in one go, it’s easy to end up with a stable PC and no idea which change got you there.
Test your RAM if the crashes seem random
One morning the browser locks up. Later, Windows crashes while you’re watching a video. The next time it displays a different stop code. That mix is a good reason to test your RAM, especially if you recently added memory or changed its speed.
If you enabled XMP or EXPO, turn off that memory profile in your BIOS or UEFI settings and test at the default memory settings. These profiles apply overclocked memory settings. If the PC runs reliably at defaults and crashes with the profile enabled, you’ve found a setting worth investigating before you buy new parts.
To run Windows Memory Diagnostic, save your work, press Windows + R, and enter mdsched.exe. Choose the option to restart and check for problems. The test runs before Windows loads. To see the result once you’re back at the desktop, open Event Viewer > Windows Logs > System and search for MemoryDiagnostics-Results.
A reported error can point to a memory stick, a motherboard slot, or the memory controller. A short test can miss an intermittent problem. If crashes continue at default settings, try the PC maker’s extended memory test if it offers one. If you contact support, tell them which test you ran and whether it found any errors.
Repair Windows files if other features are failing
Windows file repair makes sense when the blue screen comes with other trouble. Maybe an update fails every time you try it, or built-in features stopped opening around the same time. Open Command Prompt as administrator and run this command first.
DISM.exe /Online /Cleanup-Image /RestoreHealth
Once DISM reports that it finished successfully, run System File Checker.
sfc /scannow
DISM repairs the Windows component store that SFC uses as a source for clean files. SFC then checks protected Windows files and replaces damaged copies when it can. Restart after a repair and try the feature that was failing. Then test the activity that caused the crash to see whether the repair cleared up both symptoms.
Read the crash dump if the problem keeps coming back
When Windows saves a small crash dump, you’ll usually find the .dmp file in C:\Windows\Minidump. A larger dump may be saved as C:\Windows\MEMORY.DMP. If you find neither, search for View advanced system settings and go to Advanced > Startup and Recovery > Settings. Check Write debugging information. If it’s set to (none), select Automatic memory dump so Windows can save diagnostic information the next time it crashes.
Open the dump in Microsoft’s WinDbg and enter !analyze -v in the command pane. Find the bug check code first. For 0x13A, Arg1 gives you the type of damage Windows detected. A value of 0xB, for example, is consistent with code using a block of memory after freeing it.
You may see ntoskrnl.exe, the Windows kernel, in the report. The kernel can show up when it detects damage that was done earlier, and a small dump has limited information about what other code was running. If several dumps name the same third-party driver and the crashes happen during an activity that uses it, that driver deserves a closer look.
Once you’ve made a change that seems to help, give the PC a few days of the routine that used to set off the crash. Then jot down the driver version or memory setting that held up. It takes half a minute, and it’s the sort of detail you’ll be glad to have if the same stop code shows up two months from now.
