FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

RESOURCES

Use correctly ReleaseResource


Call HPurge - not ReleaseResource. You should never have to call ReleaseResource, except for some extremely rare circumstances.

Read my post "Re: Drag&Drop / Handles-pointers" made on 01/15 8:50 AM. Better yet, I'll paste the pertinent parts here so you don't have to search it up:
------------------------------------------------------------------------
It is important to understand a little bit about how the Memory Manager (MM) works. When your application creates a new handle or a new pointer (either directly or indirectly), a query is made to the MM asking for a contiguous block of memory of a certain size. The MM then scans your heap, looking for a contiguous block of free space of that size.

If it finds one, then it gives it to your app, and life goes on.

If it does not find one, then it crams everything together at one end, moving any relocatable (movable) blocks (handles) around to get the largest contiguous block that it can.

***** If there still isn't a large enough contiguous block available,
the MM will then purge any blocks that have been marked purgeable. *****

Then it checks the size of the resulting largest free block to see if it can give you what you want.

All of this happens automatically. It happens when you create windows, button, edit fields, (all of which indirectly allocate memory blocks). It happens when you call NewPtr and NewHandle. And most toolbox calls (and hence a lot of FB keywords) make it happen. In other words, it happens quite frequently - most of the time "behind the scenes" unbeknownst to you.
----------------------------------------------------------------------
I also want to point out, that the following line above:

If there still isn't a large enough contiguous block available, the MM will then purge any blocks that have been marked purgeable.

...is why we always stress that you make a handle purgeable rather than disposing of it yourself. It is always better to let the MM do what comes natural to it. The MM after all, has been bug tested a LOT more than your own code has. So let it do it's thing! ;-)

David Blache