mon application est juste s simple sendkeys. mon problème est quand je cours mon application il a utilisé environ 55-65k utilisation de la mémoire, puis quand je l'ai réduit à la barre d'état système, il descend soudainement à environ 1-3k utilisation de la mémoire, puis quand je le restaure, il s'élève à environ 6-8k d'utilisation de la mémoire. Ma question est de savoir comment puis-je réduire l'utilisation de la mémoire, même si je n'ai pas minimisé mon application?Utilisation de la mémoire de vb.net
REMARQUE: j'essaie d'attendre environ 3 minutes pour voir si mon application va réduire son utilisation de la mémoire, car je pense que c'est juste en chargeant un composant. mais je doesnt, je m'assieds sur 55-65k si je ne l'ai pas minimisé.
Voici mon code:
Imports System.Runtime.InteropServices
Imports System.Threading
Public Class Form1
Public Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Integer) As Integer
Public Declare Sub keybd_event Lib "user32" Alias "keybd_event" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
Private Declare Function GetForegroundWindow Lib "user32" Alias "GetForegroundWindow"() As IntPtr
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private SearchWindow As String
Public Const vbKeyQ = 81
Public Const vbKeyW = 87
Public Const vbKeyE = 69
Public Const vbKeyR = 82
Public Const KEYEVENTF_KEYUP = &H2
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SearchWindow = "MU"
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Control.IsKeyLocked(Keys.CapsLock) Then
Dim ForeGroundHwnd As IntPtr = GetForegroundWindow
Dim MySearchWinow As IntPtr = FindWindow(Nothing, SearchWindow)
If ForeGroundHwnd = MySearchWinow Then
If rbQ.Checked = True Then
keybd_event(vbKeyQ, 0, 0, 0)
keybd_event(vbKeyQ, 0, KEYEVENTF_KEYUP, 0)
ElseIf rbW.Checked = True Then
keybd_event(vbKeyW, 0, 0, 0)
keybd_event(vbKeyW, 0, KEYEVENTF_KEYUP, 0)
ElseIf rbE.Checked = True Then
keybd_event(vbKeyE, 0, 0, 0)
keybd_event(vbKeyE, 0, KEYEVENTF_KEYUP, 0)
ElseIf rbR.Checked = True Then
keybd_event(vbKeyR, 0, 0, 0)
keybd_event(vbKeyR, 0, KEYEVENTF_KEYUP, 0)
End If
End If
End If
End Sub
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Try
If Me.WindowState = FormWindowState.Minimized Then
Me.WindowState = FormWindowState.Minimized
NotifyIcon1.Visible = True
Me.Hide()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
Try
Me.Show()
Me.WindowState = FormWindowState.Normal
NotifyIcon1.Visible = False
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
End Class