how to free memory in vb.net when system show low memory.
how to relese memory in vb.net from system memory dump in vb.net .

Hi,

The following code will trigger the garbage collector (that is actually what it is called) to "clean" the system memory of any disposed or redundant objects

System.GC.Collect()
System.GC.WaitForPendingFinalizers()
System.GC.Collect()

I usually use this if I'm doing a series of complex code inside a loop like this:

dim iCount as integer =0

For each Widget in MyWidgets
        iCount = iCount + 1
        If (iCount Mod 100 = 0) Then
            System.GC.Collect()
            System.GC.WaitForPendingFinalizers()
            System.GC.Collect()
        End If
'..... do loads of complex stuff and functions here on my "Widget" object
Next

This should free up some memory, other than that go through your code and see if you can be more efficient when it comes to memory use.

One common area that gets abused is scope. Keep the scope for your objects as short as possible so that they gets disposed of more often.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.