Compacting Memory

You can use the following function to defragment memory, making the maximum available to your program, before beginning any operation that will require a lot of memory.

Declare

Declare Function GlobalCompact Lib "Kernel" (ByVal dwMinFree&) As Long

Code

Sub CompactMemory ()
     Dim R As Long
     R = GlobalCompact(&HFFFFFFFF)
End Sub

Usage

Call CompactMemory

 

This tip is reprinted from the VB Tips & Tricks Volume 1 book.

Compatible With Visual Basic 3.0, Visual Basic 4.0 16-bit
Applies To Windows 3