⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wguiheap.gml

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 GML
📖 第 1 页 / 共 3 页
字号:
Select many objects in a sequence by clicking on the first object and
dragging the mouse while depressing the mouse button. Release the mouse
button when the last item in the sequence is highlighted. The Add dialog
displays the number of objects selected and the total size of those
objects.
.endbull
.*
.endlevel
.*
.section Walking the Local Heap
.*
.np
.ix 'Local Heap' 'walking'
A local heap is a pool of memory set aside by an individual program from
which only that program can make allocations. Looking at the local heap
allows you to see how your program is using the memory it is taking from
the local heap.
.np
All items in the Local menu relate to objects with local heaps, so
are only functional with such objects. Objects marked with a Y in the
Heap column have a local heap.
.*
.beglevel
.*
.section Monitoring Data Segment Usage
.*
.np
.ix 'Local Heap' 'monitor'
.ix 'Monitor Local Heap function'
.ix 'DGroup' 'monitor'
Every Windows program has a default data segment.  This block of memory
contains the program's stack, local heap and the memory for any
static or extern variables that it declares (static data). If a program
requires enough static data that its default data segment grows beyond
64K then it must be recompiled for the large memory model and may encounter
problems when more than one instance of the program run simultaneously.
.np
The Monitor Local Heap item allows you to see how memory in
a program's default data segment is being used so you can optimize
this by reducing the amount of stack space allocated to the minimum
required or eliminate memory leaks that could drive up the amount of memory
required by the local heap.
.np
When you choose the Monitor Local Heap item a Local Heap Monitor
window is opened. This window contains a scale ranging from zero to
the number of bytes in the selected data segment. The scale is divided
into &colour.ed blocks which illustrate how the memory for the object
is used. Uses include:
.begpoint $break
.point Fixed heap
memory occupied by fixed objects on the program's local heap
.point Free heap
memory occupied by free objects on the program's local heap
.point Moveable heap
memory occupied by movable objects on the program's local heap
.point Stack allocated
memory allocated for use by the program's stack
.point Stack used
memory actually used by the program's stack since the program began execution
.point Static data
memory used by the program's static data
.point Unknown
memory for which Heap Walker cannot determine a use
.endpoint
.np
Heap Walker updates this display continuously as memory usage changes.
.np
To view the usage of a program's default data segment:
.begstep
.step Click once on the object containing the default data segment
you want to monitor.
.result
This object will contain a local heap.  A program's "hInstance" is the
handle of its default data segment.
.step Choose Monitor Local Heap from the Local menu.
.result
The Local Heap monitor window opens which displays the usage scale for
the selected object.
.keep 15
.figure *depth='2.25' *scale=68 *file='HW10' The Local Heap Monitor window displays a scale indicating how the selected object is used.
.step Double click on the system menu
to close the window.
.endstep
.*
.section Local Walk
.*
.np
.ix 'Local Walk'
.ix 'Heap Walker' 'local walk'
Selecting the Local Walk item from the Local menu opens the Local
Heap window for the selected object.
.keep 11
.figure *depth='1.59' *scale=72 *file='HW11' The Local Heap window displays the local heap for the selected object.
.np
This window displays all objects on the selected
object's local heap. Unlike the global heap, you cannot double
click on the local heap objects to view the data they contain.
.np
The local heap window displays the following information:
.begpoint
.point Offset
The number of bytes from the beginning of the object containing the
local heap to the beginning of the object on the local heap
.point Handle
An identifier assigned by the operating system to each object on the
local heap
.point Size
The total number of bytes occupied by the object
.point Flags
An indicator specifying the type of the object. The types are Free
(unallocated object), Fixed (allocated object that has a fixed position
on the local heap), and Moveable (allocated object that the operating
system is able to reposition on the local heap).
.point Locks
The lock count for the object
.point Type
An indicator specifying the type of information in the object
.endpoint
There are two menus in this window: File and Sort. The File menu
allows you to perform standard functions, including:
.begbull $compact
.bull
saving to a file (Save, Save As)
.bull
closing the window (Exit)
.endbull
.np
Following are other functions you can perform in the Local Heap
window.
.*
.beglevel
.*
.section Refresh the Heap
.*
.np
.ix 'Heap' 'refresh'
.ix 'Heap Walker' 'refresh heap'
The state of the local heap constantly changes as applications run.
Selecting the Refresh Local List item in the File menu updates
the information in the Local Heap window.
.*
.section Display Heap Information
.*
.np
.ix 'Heap Info'
Selecting the Heap Info item in the File menu of the Local Heap window
opens the Local Heap Information dialog box.
.keep 19
.figure *depth='3.06' *scale=100 *file='HW12' The Local Heap Information dialog displays summary information for the current local heap.
.np
This dialog displays the count and size, in bytes, of the free, moveable,
and fixed objects in the local heap for the selected object.
.np
Because the state of the local heap constantly changes, you can select
the Refresh button on the dialog to update the local heap
information. Click on OK to close the dialog.
.*
.section Sorting the Local Heap
.*
.np
.ix 'Heap' 'sort local'
.ix 'sort' 'local heap'
.ix 'local heap' 'sort'
.ix 'Heap Walker' 'sort local heap'
The Sort menu allows you to select the way Heap Walker displays the
local heap information, making objects easier to find. There are
two ways to sort information in the local heap window:
.begbull $compact
.bull
Choose the desired sort method from the Sort menu
.br
or
.br
.bull
Click once on the column heading by which you want to sort.
.endbull
.np
Only those headings appearing in the Sort menu change the organization
of the displayed information when selected.
.*
.endlevel
.*
.section Compact and Local Walk
.*
.np
.ix 'Compact Walk'
.ix 'Local Walk'
.ix 'Heap Walker' 'compact and local walk'
Selecting the Compact and Local Walk item compacts the local heap for the
selected object. Once compacted, this function opens the Local Heap
window. The functions available on this window are the same as for
the Local Walk function. This function is equivalent to making the API
call LocalCompact(-1) and then selecting Local Walk from the Local menu.
.*
.section GDI Local Walk
.*
.np
.ix 'Heap Walker' 'GDI Local Walk'
.ix 'GDI Local Walk'
GDI is the part of the Windows operating system responsible for drawing on the
screen. Much of what a Windows program does involves drawing on the
screen using objects such as device contexts, pens, and bitmaps. GDI is
responsible for managing these objects. Memory for them is contained on the
GDI Local Heap. Walking the GDI local Heap allows you to view the GDI objects
that currently exist in the system.
.np
GDI objects are a limited resource in the system, so it is important that Windows
applications use them wisely. Walking the GDI Local Heap allows you to monitor
GDI object usage.
.np
To walk the GDI Local Heap choose GDI Local Walk from the Local menu.
.*
.section USER Local Walk
.*
.np
.ix 'USER Local Walk'
.ix 'Heap Walker' 'USER Local Walk'
USER is the part of the Windows operating system responsible for
managing user interface objects such as windows, menus, and dialogs.
Some memory associated with these objects is contained on the USER Local
Heap.
.np
Space on the USER Local Heap is a limited resource in the system, so it is important
that Windows applications use it wisely. Walking the USER Local Heap allows
you to monitor usage of this space.
.np
To walk the USER Local Heap choose USER Local Walk from the Local menu.
.*
.endlevel
.*
.section Working with the Global Heap
.*
.np
.ix 'Global Heap'
.ix 'Heap Walker' 'Global Heap'
The global heap is a pool of memory set aside by the system from which all
program memory is allocated. There are five functions you can use to
monitor and manipulate the Global Heap. This section describes these
functions.
.*
.beglevel
.*
.section Refreshing the Global Heap
.*
.np
As programs run, the state of the global heap changes. When you
select the global heap window after a window belonging to
another application has been active, Heap Walker automatically
refreshes the displayed global heap information.
.np
.ix 'Global Heap' 'refresh'
.ix 'Refreshing Displayed Information'
Selecting the Refresh Global Heap item in the Global menu forces Heap Walker
to update the displayed global heap information.
.*
.section Compacting the Global Heap
.*
.np
.ix 'Global Heap' 'compacting'
.ix 'Global Compact item'
.ix 'Global Heap' 'compacting'
Compacting the global heap creates larger blocks of free memory.
The system automatically compacts the global heap when it needs
memory.
.np
The Global Compact item in the Global menu allows you to
manually force the system to compact the global heap. Selecting this item
is equivalent to making the API call GlobalCompact(0).
.*
.section Removing Discardable Objects
.*
.np
.ix 'Object' 'removing discardable'
.ix 'Removing Discardable Objects'
Selecting the Global Compact and Discard item  from the Global menu
removes all discardable objects and compacts the free memory on the
global heap. This allows you to create larger blocks of free memory.
Selecting this item is equivalent to making the API call GlobalCompact(-1).
.*
.section Viewing the Global Heap Summary
.*
.np
.ix 'Global Heap' 'summary'
Selecting the Global Heap Info item from the Global Menu opens a
Global Heap Information dialog box. This dialog summarizes global
heap usage.
.keep 15
.figure *depth='2.30' *scale=100 *file='HW13' The Global Heap Information dialog provides a summary of global heap usage.
.np
Information included on this dialog is:
.begbull $compact
.bull
Total Items on the Heap
.bull
Number of Free Items
.bull
Number of LRU Items
.endbull
.np
The state of the global heap changes as applications run.
Select the Refresh button to update the global heap summary. Click
on OK to close the dialog.
.*
.section Viewing Memory Management Information
.*
.np
.ix 'Memory Management Information'
Selecting the Memory Management Info item from the Global menu opens
a Memory Management Information dialog box. This dialog displays
information regarding the state of the virtual memory manager.
.keep 17
.figure *depth='2.69' *scale=66 *file='HW14' The Memory Management Information dialog displays information regarding the state of the virtual memory manager.
.np
Following is the information that appears on this dialog.
.begpoint $break
.point Size of Linear Address Space (in pages)
The size of the total linear address space in pages
.point Free Pages in Linear Address Space
The amount of free memory, in pages, in the linear address space
.point System Page Size (in bytes)
The size, in bytes, of a page of memory
.point Pages in Swap File
The number of pages in the system swap file
.point Total Pages in System
The total number of pages managed by the virtual memory manager, including free, locked, and
unlocked pages
.point Number of Unlocked Pages
The number of unlocked pages in the system, including free pages
.point Number of Free Pages
The number of pages in the system that are not currently in use
.point Largest Free Memory Block
The size, in bytes, of the largest free block of contiguous linear memory in the system
.point Maximum Allocatable Pages
The maximum number of pages that are available in the system for allocation
.point Maximum Lockable Pages
The maximum number of pages that are available in the system to be allocated and locked
.endpoint
.np
The information displayed by this dialog changes as applications
run. Click on the Refresh button to update the displayed information.
Click on OK to close the Memory Management Information dialog.
.*
.endlevel
.*
.section Testing with Heap Walker
.*
.np
.ix 'Heap Walker' 'testing with'
Heap Walker provides various allocation functions that allow
you to test your programs. By allocating and freeing memory you
can see how your program reacts in low memory situations.
.np
Each time you select the Alloc menu an Allocation Information
dialog box appears on the screen.
.keep 11
.figure *depth='1.52' *scale=100 *file='HW15' The Allocation Information dialog provides approximate size information regarding allocated and free memory.
.np
The information in this dialog
includes Kilobytes allocated (approximately), Kilobytes free, and
Bytes free. It is important to realize that the information appearing
in this dialog is approximate. This information appear so you can monitor
the approximate amounts of memory you have allocated using an Allocation
function. You should use this information only when using an Allocation
function.
.begnote
.mnote Important:
Do not use the Allocation functions under the Windows Debug Kernel as
they can make your system unstable.
.endnote
.*
.beglevel
.*
.section Allocate All Memory
.*
.np
.ix 'Allocate All Memory'
.ix 'Memory' 'Allocate All'
To see how your program runs when all free memory is allocated,
choose Allocate All Memory from the Alloc menu. Choosing this item may
change the appearance and performance of your application. This is
normal because when there is little memory available, the system
may discard fonts that Heap Walker is using and swap information
to disk more frequently.
.*
.section Free All Memory
.*
.np
.ix 'Free All Memory'
.ix 'Memory' 'Free All'
Selecting the Free All Memory item frees all of the allocated memory. This
returns to the system the memory taken away using other Allocation
functions.
.*
.section Other Allocation Functions
.*
.np
.ix 'Allocate all but'
.ix 'Allocate'
.ix 'Free'
The final three allocation functions&mdash.Allocate all but, Allocate, and
Free&mdash.allow you to choose an amount of memory to allocate
or free. Perform these functions as follows:
.begstep
.step Choose the desired function
from the Alloc menu.
.step Choose the desired amount of memory
that you want to allocate, free, or leave unallocated.
.result
For all functions, an n amount is available. Selecting this item
closes the Allocation Information dialog box and opens
a separate dialog box displaying the following information:
.begbull $compact
.bull
K Allocated (approx.)
.bull
K free (approx.)
.bull
Bytes Free
.endbull
.keep 16
.figure *depth='2.44' *scale=100 *file='HW16' On the allocation dialog box, enter the desired amount of memory to allocate, free, or leave unallocated.
.step In this dialog, enter the specific number of bytes to Allocate
all but, Allocate, or Free.
.result
The system interprets the entered value as bytes, unless you follow the
value with a K, in which case the value is read as kilobytes. You can
enter Hexadecimal values by prefixing them with 0x.
.step Click on OK
to process the request and close the dialog.
.endstep
.*
.endlevel
.*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -