-1

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 .

3
Contributors
2
Replies
17
Views
4 Years
Discussion Span
Last Post by tinstaafl
0

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.

Edited by G_Waddell: Need to learn to touch type

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.