Differences
This shows you the differences between two versions of the page.
| en:docs:win16:api:kernel:localshrink [2023/05/01 13:58] – created prokushev | en:docs:win16:api:kernel:localshrink [2026/03/04 06:49] (current) – prokushev | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| {{page> | {{page> | ||
| - | ====== | + | ====== |
| + | (Source: Windows 3.0 SDK, Microsoft Knowledge Base Article Q21581) | ||
| ===== Brief ===== | ===== Brief ===== | ||
| + | Shrinks the specified local heap to the size given by the wSize parameter. The minimum size for the automatic local heap is defined in the application' | ||
| ===== Syntax ===== | ===== Syntax ===== | ||
| + | <code c>WORD WINAPI LocalShrink( | ||
| + | HANDLE hSeg, | ||
| + | WORD wSize | ||
| + | );</ | ||
| ===== Parameters ===== | ===== Parameters ===== | ||
| - | ===== Return | + | hSeg – Handle (selector) of the segment that contains the local heap. If hSeg is zero, the function reduces the local heap in the current data segment (DGROUP) . |
| + | |||
| + | wSize – Specifies the desired size of the local heap after shrinkage, in bytes . | ||
| + | |||
| + | ===== Return | ||
| + | The return value specifies the actual size of the local heap after shrinkage, in bytes . If the heap could not be shrunk to the requested size, the return value may be larger than wSize. | ||
| ===== Notes ===== | ===== Notes ===== | ||
| - | ===== Example Code ===== | + | Windows will not shrink that portion of the data segment that contains the stack and the static variables . |
| + | When an application calls LocalAlloc and there is not enough memory within the application' | ||
| + | |||
| + | LocalShrink cannot move FIXED or locked blocks when compacting the local heap. Therefore, free space may still remain in the heap, and the final size may not be as small as requested. The function compacts as much as possible given this constraint . | ||
| + | |||
| + | To determine the new size of the whole data segment, use the GlobalSize function . | ||
| + | |||
| + | This function is rarely used in practice; Windows usually manages the local heap size automatically. | ||
| + | |||
| + | ===== Example Code ===== | ||
| ==== C Binding ==== | ==== C Binding ==== | ||
| + | <code c># | ||
| + | // Shrink the local heap of the current data segment to 256 bytes | ||
| + | WORD wNewSize = LocalShrink(0, | ||
| ==== MASM Binding ==== | ==== MASM Binding ==== | ||
| + | <code asm>; AX = segment handle (0 for current data segment), BX = desired size in bytes | ||
| + | push ax ; hSeg | ||
| + | push bx ; wSize | ||
| + | call LocalShrink ; Returns AX = new heap size</ | ||
| ===== See also ===== | ===== See also ===== | ||
| + | |||
| + | * [[LocalInit]] | ||
| + | * [[LocalAlloc]] | ||
| + | * [[LocalCompact]] | ||
| + | |||
| + | |||
| {{page> | {{page> | ||




