wailsapp/wails · error

GlobalAlloc failed

Error message

GlobalAlloc failed

What it means

Error "GlobalAlloc failed" thrown in wailsapp/wails.

Source

Thrown at v3/pkg/w32/kernel32.go:125

func Lstrlen(lpString *uint16) int {
	ret, _, _ := procLstrlen.Call(uintptr(unsafe.Pointer(lpString)))

	return int(ret)
}

func Lstrcpy(buf []uint16, lpString *uint16) {
	procLstrcpy.Call(
		uintptr(unsafe.Pointer(&buf[0])),
		uintptr(unsafe.Pointer(lpString)))
}

func GlobalAlloc(uFlags uint, dwBytes uint32) HGLOBAL {
	ret, _, _ := procGlobalAlloc.Call(
		uintptr(uFlags),
		uintptr(dwBytes))

	if ret == 0 {
		panic("GlobalAlloc failed")
	}

	return HGLOBAL(ret)
}

func GlobalFree(hMem HGLOBAL) {
	ret, _, _ := procGlobalFree.Call(uintptr(hMem))

	if ret != 0 {
		panic("GlobalFree failed")
	}
}

func GlobalLock(hMem HGLOBAL) unsafe.Pointer {
	ret, _, _ := procGlobalLock.Call(uintptr(hMem))

	if ret == 0 {
		panic("GlobalLock failed")

View on GitHub (pinned to 0e754b1b40)

Solutions

  1. Reduce the requested allocation size (dwBytes); GlobalAlloc fails when the system cannot satisfy the memory request.
  2. Use valid allocation flags such as GMEM_MOVEABLE or GMEM_FIXED; invalid flag combinations cause failure.
  3. Check for memory or handle exhaustion; free unused global memory blocks with GlobalFree.

When it happens

Trigger: Occurs when GlobalAlloc returns NULL, typically due to insufficient memory or invalid allocation flags.

Common situations: See trigger scenarios.


AI-assisted analysis of wailsapp/wails@0e754b1b40 (2026-08-15). Data as JSON: /api/errors/404c989523dd6f36. Report an issue: GitHub.