Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 [WTA] VB.Net - Memory comsuming, how to minimized memory used

views
     
sinx
post Feb 28 2006, 09:11 AM

New Member
*
Junior Member
15 posts

Joined: Aug 2005


Here come with my dirty trick!
Try to call FlushMemory() in every XX seconds then you can see the effect.
Remember, this is DIRTY way. It might NOT REALLY reduce memory usage but i think no harm to try.

CODE
Public Class MemoryManagement

   Private Declare Function SetProcessWorkingSetSize Lib "kernel32.dll" ( _
   ByVal process As IntPtr, _
   ByVal minimumWorkingSetSize As Integer, _
   ByVal maximumWorkingSetSize As Integer) As Integer

   Public Shared Sub FlushMemory()

       GC.Collect()
       GC.WaitForPendingFinalizers()

       If (Environment.OSVersion.Platform = PlatformID.Win32NT) Then
           SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1)
       End If

   End Sub
End Class


 

Change to:
| Lo-Fi Version
0.0136sec    0.33    6 queries    GZIP Disabled
Time is now: 24th December 2025 - 06:34 AM