Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Declare Auto Function SetProcessWorkingSetSize Lib "kernel32.dll" (ByVal procHandle As IntPtr, ByVal min As Int32, ByVal max As Int32) As Boolean
- Public Class FreeMemory
- 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()
- Try
- GC.Collect()
- GC.WaitForPendingFinalizers()
- If (Environment.OSVersion.Platform = PlatformID.Win32NT) Then
- SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1)
- End If
- Catch ex As Exception
- End Try
- End Sub
- End Class
- Public Sub SetProcessWorkingSetSizeEx()
- Dim mProc As Process
- mProc = Process.GetCurrentProcess()
- ' Imported function call
- SetProcessWorkingSetSize(mProc.Handle, -1, -1)
- End Sub
- Public Sub New()
- MyBase.New()
- 'This call is required by the Windows Form Designer.
- InitializeComponent()
- 'Add any initialization after the InitializeComponent() call
- End Sub
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
- Private Sub CLEAR_Tick(sender As Object, e As EventArgs) Handles CLEAR.Tick
- SetProcessWorkingSetSizeEx()
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement