Fix Error 781: Insufficient Resource for Shared Section Size
Date Updated
If Windows shows error insufficient resource for specified shared section size, you are almost certainly looking at a desktop heap problem, not a failing disk or a broken driver. The formal name of the message is ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE, Win32 error code 781 (0x30D), and it means the desktop heap could not allocate the session memory it needed. In practice this appears as windows that refuse to open, dialogs with missing buttons, generic "out of memory" prompts on a machine with gigabytes of free RAM, or new processes that fail with 0xc0000142.
This guide explains what the error really means, how to prove the cause from the event log, how to size the SharedSection registry values correctly, and which popular "fixes" (more RAM, a bigger page file, driver reinstalls) do and do not help.
Table of Contents#
- What Is ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE?
- How Sessions, Desktops, and Desktop Heaps Work
- The SharedSection Values Explained
- Symptoms and Where This Error Hits Hardest
- Step 1: Confirm the Cause in the Event Log
- Step 2: Reduce Desktop Heap Pressure
- Step 3: Increase the Desktop Heap (SharedSection Registry Edit)
- Step 4: What About RAM and the Page File?
- Step 5: Update or Reinstall Drivers and UI Components
- Best Practices for Desktop Heap Capacity
- Common Mistakes to Avoid
- Conclusion
- References
What Is ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE?#
ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE is a standard Win32 system error code. Microsoft's WinError.h documentation defines it as:
781 (0x30D) — The Desktop heap encountered an error while allocating session memory. There is more information in the system event log.
Two points are worth internalizing before you touch anything:
- It is a Win32 allocation failure, not a blue-screen stop code. The error surfaces through
GetLastError()(or as HRESULT0x8007030Din .NET/COM tooling) when something tries to create a window, desktop, or session UI object and the shared section that backs the desktop heap is exhausted. You may see stability problems alongside it, but the code itself is not a bugcheck, so memory diagnostics and crash dumps are usually the wrong first move. - The system event log really does hold the details. The message points you there on purpose. On modern Windows, the desktop subsystem logs a Win32k event with the process that failed, and that single piece of information usually identifies the leak.
Error 781 sits in the 500–999 band of the Windows system error codes. Its symptoms overlap with generic resource errors such as ERROR_NOT_ENOUGH_MEMORY and ERROR_NOT_ENOUGH_QUOTA, which is why desktop heap problems are so often misdiagnosed as ordinary out-of-memory conditions.
How Sessions, Desktops, and Desktop Heaps Work#
To fix the error permanently, you need a working mental model of the objects involved. Windows organizes interactive work like this:
- Session — everything that represents one user's logon: processes, window stations, desktops, and the memory that backs them. Every signed-in user gets a session, and Session 0 is the isolated session where background services run.
- Window station — a security boundary that owns one or more desktops. The interactive window station (
WinSta0) is the only one that can display output to the user; services normally run in non-interactive window stations created by the Service Control Manager (for exampleService-0x0-3e7$). - Desktop — the logical display surface that lives under a window station. It holds windows, menus, hooks, and strings.
WinSta0ships with the Default, ScreenSaver, and Winlogon desktops, which is why locking the workstation can swap what you see without ending your session. - Desktop heap — the per-desktop pool of session memory from which
User32.dllallocates those UI objects. Every desktop gets its own heap. Desktop heaps live in the session's mapped view space (session view space) inside kernel memory; when that space or a heap's quota is exhausted, window creation fails.
Because each desktop owns a separate heap, the failure is scoped. If one desktop's heap is full, only the processes using that desktop degrade. If the session's view space is depleted, the whole session misbehaves. Session 0 is the dangerous case: its heap is deliberately tiny because services are not supposed to draw UI, so Session 0 exhaustion causes seemingly unrelated failures machine-wide and is notoriously hard to trace.
Historically (pre-Windows Vista), Win32k reserved a fixed 48 MB kernel region for desktop heaps, and Terminal Services had to share it — leaving roughly 20 MB for all desktops together. On Windows Vista and later, desktop heap allocation is dynamic and that fixed ceiling is gone. But "dynamic" does not mean "unlimited": each desktop is still capped by a configured size, and that size is what error 781 is complaining about.
The SharedSection Values Explained#
Desktop heap sizes are controlled by one registry string: the Windows value under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems
Inside the value data (a long command line that starts the client/server runtime subsystem) you will find a parameter named SharedSection with three numbers, all in kilobytes:
SharedSection=1024,20480,768
| Position | Meaning | Scope | Typical default (64-bit) |
|---|---|---|---|
| 1st | Shared heap used by all desktops — global handle table and shared system settings | System-wide | 1024 KB |
| 2nd | Desktop heap for each desktop in an interactive window station (WinSta0) — windows, menus, hooks, strings | Per interactive desktop | 20480 KB |
| 3rd | Desktop heap for each desktop in a non-interactive window station | Per service desktop | 768 KB |
The defaults above are the values shipped on 64-bit Windows since Windows 7 SP1 / Windows Server 2008 R2 (1024, 20480, 768). Older 32-bit systems used smaller numbers such as 1024, 12288, 512. Always read the value on the affected machine instead of assuming — many hardening scripts and vendor installers change it.
Behavior that surprises people:
- The second value is per desktop, not per machine. Ten users signed in means ten interactive desktop heaps, each of that size.
- The third value is what services consume. Every service process created under a user account gets its own desktop in a non-interactive window station, and each of those desktops reserves the third value's worth of heap. A host with dozens of such services can exhaust non-interactive heap long before a workstation does.
- If the third value is missing, non-interactive desktops are sized like interactive ones.
- The first value is shared infrastructure and generally should not be edited.
Symptoms and Where This Error Hits Hardest#
Desktop heap exhaustion rarely announces itself with a clean message. Typical symptoms include:
- New windows fail to appear, or appear broken — missing buttons, scroll bars, or title bars.
- Generic "out of memory" or "not enough quota" errors from applications while Task Manager shows plenty of free RAM.
- New processes failing at startup with
0xc0000142(STATUS_DLL_INIT_FAILED), because DLLs that create UI during process initialization cannot allocate from the heap. - The System log entry Event ID 243, source Win32k: "A desktop heap allocation failed." On recent Windows builds the event includes the process ID, process name, thread ID, and session ID.
- On multi-session hosts, individual users hit the wall while others are fine; or the whole box degrades when Session 0 is the exhausted one.
Environments where this shows up repeatedly:
- Remote Desktop / multi-session session hosts, where interactive desktop heaps multiply with every signed-in user.
- Service-heavy servers — print servers, backup agents, monitoring agents, build workers — where many services run under user accounts and therefore own non-interactive desktops.
- Long-running workstations with dozens of browser tabs, MDI applications, or automation tools that create thousands of windows and never release them.
- Kiosks and trading/ops desks that stay signed in for weeks, letting object leaks accumulate.
A key diagnostic detail: closing some windows and opening others may appear to help, because freed slots are reused, but that does not raise the ceiling. The failure returns at roughly the same total number of UI objects.
Step 1: Confirm the Cause in the Event Log#
Before changing anything, prove that this is a desktop heap problem and find out who is eating the heap.
-
Open Event Viewer and check the System log around the time of the failure.
-
Look for Win32k, Event ID 243 ("A desktop heap allocation failed"). Recent Windows versions name the culprit:
A desktop heap allocation failed. Process ID: 14012. Process name: conhost.exe. Thread ID: 14260. Session ID: 0 -
Note that the event is logged only once per session, so the timestamp can be hours earlier than the moment you noticed symptoms.
You can pull the same data from an elevated PowerShell prompt:
Get-WinEvent -FilterHashtable @{ LogName = 'System'; Id = 243 } -MaxEvents 20 |
Format-List TimeCreated, ProviderName, MessageTo see the current desktop heap configuration on the machine:
$key = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems'
(Get-ItemProperty -Path $key -Name Windows).WindowsInterpret the results like this:
- Session ID 0 and a service-like process → non-interactive / Session 0 pressure. Treat this as urgent; it destabilizes the whole system.
- A single user session and a named application → that app is leaking UI objects. Fix the app first; only then consider raising limits.
- Many different processes → genuine capacity shortage (too many users, services, or desktops for the configured heap sizes).
Step 2: Reduce Desktop Heap Pressure#
If the events point to a specific process, the safest fix is to stop the leak rather than raise the ceiling.
- Restart or update the offending application. Look for known issues with the exact version the event names; UI object leaks in browser add-ins, shell extensions, and print drivers are common culprits.
- Sign off idle user sessions on shared hosts. Each signed-out session releases its interactive desktop heap.
- Close unneeded windows and reduce always-on UI (tray tools, monitoring dashboards, preview panes) on long-running workstations.
- Review services configured to run under user accounts. Each one costs a non-interactive desktop heap. Where possible, run services as
LocalSystem/NetworkServicewithout UI, or consolidate them. - Reboot as a stopgap. A reboot clears all heaps and buys time, but if the leak persists the failure will recur.
Step 3: Increase the Desktop Heap (SharedSection Registry Edit)#
When demand is legitimate (many users, many services, a genuinely UI-heavy workload), raise the limits. This is the documented remedy for desktop heap limitation errors.
Back up first#
Registry mistakes here can prevent Windows from starting. Export the key before editing:
reg export "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems" C:\Backup\subsystems.regOr in Registry Editor: File → Export and save the .reg file somewhere you can reach from recovery media.
Edit SharedSection#
- Press
Win + R, runregedit, and accept the UAC prompt. - Go to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems. - In the right pane, double-click the Windows value.
- Copy the entire value data into Notepad — it is one long line and you must not damage the rest of it. Find
SharedSection=1024,20480,768(your numbers may differ). - Decide which value to change:
- Second value (interactive desktop heap): raise it if users see broken windows or cannot open new ones. On modern 64-bit systems it is already 20480 KB — the documented maximum. Do not exceed 20480 KB.
- Third value (non-interactive desktop heap): raise it if the Event 243 entries point at services or Session 0. A common, conservative step is
768 → 2048or768 → 4096.
- Paste the edited string back into Value data, click OK, and restart Windows. These settings are read at boot.
Example: a service host with many services under user accounts might move from
SharedSection=1024,20480,768
to
SharedSection=1024,20480,2048
How far is safe?#
- Increase only as much as needed, in small steps of about 512 KB (long-standing platform guidance), then reboot and re-check the event log.
- Oversized values are not free. Making heaps bigger does not create more memory; it trades off how many desktops can exist against how many UI objects each desktop may hold. Raising the third value, for example, reduces how many user-account services the system can host successfully.
- Values that are far too large can leave the machine unable to finish Session 0 setup at startup — a no-boot condition. If that happens, boot from recovery media, load the offline hive, and restore your exported
.regfile. - Microsoft's guidance is blunt: under normal circumstances do not increase the desktop heap; change it only when you have evidence you need it. The article also notes that the Session 0 desktop heap cannot be modified this way, and that these settings apply to user desktop heaps.
Step 4: What About RAM and the Page File?#
This is where a lot of generic advice goes wrong.
- Adding physical RAM does not enlarge desktop heaps. Microsoft's desktop heap documentation states that the physical RAM in the computer does not affect desktop heap size and that you cannot improve this by adding RAM.
- Enlarging the page file does not raise the SharedSection caps. The heap sizes you hit are configured values, not a function of commit limit. If the machine is genuinely starved of commit (visible as "out of memory" errors system-wide, high commit charge in Task Manager), letting Windows manage the paging file — or giving it more room — is reasonable general hygiene, but it will not resolve error 781 on its own.
- What does help is capacity planning: fewer simultaneous sessions, fewer UI-heavy processes per session, fewer user-account services, and only then a modest
SharedSectionincrease sized from real event-log evidence.
Step 5: Update or Reinstall Drivers and UI Components#
Driver work is a secondary step, and only in one situation: the Event 243 data implicates a driver or shell component (graphics filter drivers, print drivers, accessibility hooks) that is leaking UI objects.
- Press
Win + R, rundevmgmt.msc. - Check for devices marked with a warning triangle; start with Display adapters, Print queues, and Sound/video controllers.
- Right-click the device → Update driver → Search automatically for drivers. If Windows finds nothing, install the vendor's current signed driver from the manufacturer's support site.
- If problems started right after an update, use Uninstall device (check "Attempt to remove the driver" where offered), reboot, and reinstall a known-good version.
Skip this step if the events show ordinary applications consuming heap — reinstalling drivers will not move that number.
Best Practices for Desktop Heap Capacity#
-
Leave
SharedSectionat the shipped defaults on ordinary workstations. Raise it only against documented Event 243 evidence. -
Baseline the System log on busy hosts. A scheduled query for Win32k Event ID 243 turns an obscure failure into an early warning:
$hits = Get-WinEvent -FilterHashtable @{ LogName = 'System'; Id = 243; StartTime = (Get-Date).AddDays(-7) } -ErrorAction SilentlyContinue if ($hits) { $hits | Format-List TimeCreated, Message | Out-File C:\Logs\desktopheap.log } -
Size interactive heaps for session count on RDS/Citrix hosts. Remember the second value is per desktop, and each signed-in user creates desktops.
-
Budget non-interactive heaps for services. Count services that run under user accounts, multiply by the third value, and leave headroom for growth.
-
Prefer fixing the leaking application. Raising a ceiling buys time; it never fixes a leak.
-
Change one value at a time, reboot, and watch the event log before and after. Keep the exported registry file until the change has proven stable across a business cycle.
-
Test on a non-production host first on servers. A bad edit to the
Windowsvalue is a boot-time dependency.
Common Mistakes to Avoid#
- Treating the error as a BSoD and chasing hardware. Error 781 is a session-memory allocation failure in the desktop heap. Dump analysis and memtest are rarely the fastest path.
- "Increasing" the second value to 3072 or 4096. On modern 64-bit Windows the default is already 20480 KB. Setting 4096 would cut the interactive heap to a fifth of its default size and make things worse.
- Exceeding 20480 KB for the second value. This is explicitly documented as out of bounds.
- Assuming more RAM or a bigger page file fixes it. It does not affect desktop heap size.
- Editing the
Windowsvalue carelessly. It is a long, single-line command string. A typo in the wrong place can make the system unbootable. Always export first, edit a copy in Notepad, and paste back only theSharedSectionnumbers you changed. - Ignoring Session 0 events. Failures logged with Session ID 0 affect every user and every service; escalate them immediately.
- Raising the third value indefinitely on service hosts. Bigger per-service heaps reduce the number of service desktops the system can sustain. Validate on a lab host.
- Believing that closing and reopening windows resets the limit. It only reuses freed slots; the ceiling is unchanged.
Conclusion#
ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE (error 781 / 0x30D) means the desktop heap ran out of session memory while allocating UI objects — windows, menus, hooks, and strings. The reliable fix path is:
- Confirm the cause in the System log (Win32k Event ID 243, including process and session).
- Reduce pressure by fixing leaking applications, closing idle sessions, and cutting unnecessary user-account services.
- Resize
SharedSectionunderSession Manager\SubSystemsonly if real demand requires it — the second value for interactive desktops (never above 20480 KB), the third for service desktops — with a registry backup and a reboot. - Ignore generic memory advice. More RAM and a larger page file do not enlarge desktop heaps; driver updates help only when a driver is the leak.
Treat desktop heap as a capacity budget, not an unlimited pool: measure first, change minimally, and let the event log tell you whether the change worked.
References#
- Microsoft, System Error Codes 500–999 (WinError.h) — definition of error 781 (0x30D) and its message text.
- Microsoft Support, Fix Desktop Heap Limitation and Out of Memory Errors (KB 947246) — Event ID 243 details,
SharedSectionsemantics, the 20480 KB limit, and the note that physical RAM does not affect desktop heap size. - Microsoft AskPERF, Sessions, Desktops and Windows Stations — session/window station/desktop model, shared vs. interactive vs. non-interactive heaps, and service desktop behavior.
- Microsoft, About Window Stations and Desktops — window station and desktop object model used by Win32 applications.
- Microsoft, Desktops — default desktops in the interactive window station.
- Microsoft Support, How to back up and restore the registry in Windows — registry backup procedure before editing
SharedSection.