Advertisement
ivandrofly

Clear the memory Cache

May 4th, 2014
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.75 KB | None | 0 0
  1. Declare Function:
  2. SetProcessWorkingSetSize Lib "kernel32.dll" (ByVal process As IntPtr, ByVal minimumWorkingSetSize As Integer, ByVal maximumWorkingSetSize As Integer) As Integer
  3. Flush Code:
  4. Public Sub FlushMemory()
  5.     Try GC.Collect()
  6.     GC.WaitForPendingFinalizers()
  7.     If (Environment.OSVersion.Platform = PlatformID.Win32NT) Then
  8.         SetProcessWorkingSetSize(Process.GetCurr­entProcess().Handle, -1, -1)
  9.         Dim myProcesses As Process() = Process.GetProcessesByName("ApplicationN­ame")
  10.         Dim myProcess As Process
  11.         Dim ProcessInfo As Process
  12.     For Each myProcess In myProcesses
  13.         SetProcessWorkingSetSize(myProcess.Handl­e, -1, -1) Next myProcess
  14.     End If Catch ex As Exception End Try End Sub
  15. Code found: https://www.youtube.com/watch?v=-fPY7ecWPUA#t=282
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement