メモリクリーナーをVBで作成しています。
しかし、現在の方法ではうまくメモリの解放ができません。
Private Declare Function VirtualAlloc Lib "kernel32" (lpAddress As Any, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFree Lib "kernel32" (lpAddress As Any, ByVal dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Sub FillMemory Lib "kernel32" Alias "RtlFillMemory" (dest As Any, ByVal numBytes As Long, ByVal Fill As Byte)
Dim lpMem as long 'アドレス保存用変数
Dim lngByte as Long '掃除するサイズ
'掃除するメモリーのサイズを設定
lngByte=Val(Command$) 'コマンドラインからサイズを決定
If lngByte=0 Then lngByte=32 '未指定で32メガバイトとする
lngByte=lngByte * 1024& * 1024& 'メガバイトをバイトに変換
'メモリーの掃除
lpMem=VirtualAlloc(ByVal 0, lngByte, &H1000, &H4 Or &H200)
Call FillMemory(ByVal lpMem, lngByte, 0)
Call VirtualFree(lpMem, lngByte, MEM_RELEASE)
↑でメモリーの掃除はできているのでしょうか。教えてください。
ツイート | ![]() |