>"The GlobalCompact function is obsolete. It is provided only for
compatibility with 16-bit versions of Windows. It has no meaning in the
32-bit environment."
A good idea, though. I’m amazed such a function ever existed - it’s almost
an admission of poor memory management design in the operating system.
Under Windows 2.x, memory management was all handled in software. There was
no memory mapping hardware. GlobalAlloc returned a opaque handle to a
memory block, and then you would do GlobalLock to get an actual pointer to
the memory.
Over time, memory would get fragmented, and you would periodically call
GlobalCompact to reorder memory. Handles you had didn’t change.
As a side note, memory STILL get’s fragmented, it’s just there is nothing
you can do about now. I haven’t measured it in some years, but in the past
had often seen cases where the 32-bit heap took twice as much memory as the
allocated blocks in it. Worst case allocation/freeing patterns can get a
LOT worse. I guess everybody decided it was ok for our apps to consume
twice as much memory as they really needed.
A big advantage of a language that uses compacting garbage collection
(typically like Java/Smalltalk/Visual Basic/others) is this fragmentation
is handled. Under C++/C, memory fragments, sometimes badly, and there is
nothing you can really do about it.
Also note that taking some random bunch of code it’s not possible to
predict what the end stable memory utilization factor will be, it will
depend on an interaction between the allocation/freeing patterns and the
specific memory allocator algorithms (which may be changed by the OS or
language developer). It’s also possible it will not be stable, and memory
consumption will grow forever.
Kernel memory also can get fragmented over time.
Probably the difference now vs. 16-bit Windows days is we commonly have 128
MByte instead of 0.5 MByte total available. In those days, loosing 0.25
MByte to fragmentation would have been unthinkable. Losing 64 MByte now
slows down you system, but generally not to a crawl.
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com