AU3 GUI窗口占用内存怎么这么大
本帖最后由 iori2882 于 2012-4-26 14:54 编辑下面就是一段普通的窗口 占用内存11.28兆 这个占用内存量正常么?我感觉有点大啊?我看360安全卫士美工作完了占用内存7.8兆,大家都这样么????
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIListBox.au3>
#include <ProgressConstants.au3>
Global Const $SC_MOVE = 0xF010
$Form1 = GUICreate("Form1", 613, 401, 292, 124, $WS_POPUP)
$Pic1 = GUICtrlCreatePic("", 0, 0, 613, 401, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_DISABLE);使控件不可用
$Button1 = GUICtrlCreateButton("电话查询", 8, 21, 67, 67)
$Button3 = GUICtrlCreateButton("IP相关", 96, 21, 67, 67)
$Button5 = GUICtrlCreateButton("实用应用", 184, 21, 67, 67)
$Button7 = GUICtrlCreateButton("校园内网", 272, 21, 67, 67)
$Button9 = GUICtrlCreateButton("备用", 360, 21, 67, 67)
$Button11 = GUICtrlCreateButton("备用", 448, 21, 67, 67)
$Button13 = GUICtrlCreateButton("管理员", 536, 21, 67, 67)
$Button2 = GUICtrlCreateButton("X", 584, 0, 17, 17)
$Button4 = GUICtrlCreateButton("□", 560, 0, 17, 17)
$Button6 = GUICtrlCreateButton("一", 536, 0, 17, 17)
$Progress1 = GUICtrlCreateProgress(0, 90, 613, 6)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
;=============================================================建立分页面一==================
$ne_gui1 = GUICreate("", 610, 285, 4, 101, $WS_POPUP, $WS_EX_MDICHILD, $Form1)
$Pic2 = GUICtrlCreatePic("", 0, 0, 619, 284, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_DISABLE);使控件不可用
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $GUI_EVENT_PRIMARYDOWN
_SendMessage($Form1, $WM_SYSCOMMAND, $SC_MOVE + $HTCAPTION, 0)
Case $Button2
ExitLoop
EndSwitch
WEnd
GUIDelete()
做什么用的? 做什么用的?
lxzan 发表于 2012-4-26 08:35 http://www.autoitx.com/images/common/back.gif
...就一个普通窗口,你复制代码运行下就知道了 回复 3# iori2882
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIListBox.au3>
#include <ProgressConstants.au3>
Global Const $SC_MOVE = 0xF010
$Form1 = GUICreate("Form1", 613, 401, 292, 124, $WS_POPUP)
$Pic1 = GUICtrlCreatePic("", 0, 0, 613, 401, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_DISABLE);使控件不可用
$Button1 = GUICtrlCreateButton("电话查询", 8, 21, 67, 67)
$Button3 = GUICtrlCreateButton("IP相关", 96, 21, 67, 67)
$Button5 = GUICtrlCreateButton("实用应用", 184, 21, 67, 67)
$Button7 = GUICtrlCreateButton("校园内网", 272, 21, 67, 67)
$Button9 = GUICtrlCreateButton("备用", 360, 21, 67, 67)
$Button11 = GUICtrlCreateButton("备用", 448, 21, 67, 67)
$Button13 = GUICtrlCreateButton("管理员", 536, 21, 67, 67)
$Button2 = GUICtrlCreateButton("X", 584, 0, 17, 17)
$Button4 = GUICtrlCreateButton("□", 560, 0, 17, 17)
$Button6 = GUICtrlCreateButton("一", 536, 0, 17, 17)
$Progress1 = GUICtrlCreateProgress(0, 90, 613, 6)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
;=============================================================建立分页面一==================
$ne_gui1 = GUICreate("", 610, 285, 4, 101, $WS_POPUP, $WS_EX_MDICHILD, $Form1)
$Pic2 = GUICtrlCreatePic("", 0, 0, 619, 284, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_DISABLE);使控件不可用
GUISetState(@SW_SHOW)
While 1
_ReduceMemory(@AutoItPID)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $GUI_EVENT_PRIMARYDOWN
_SendMessage($Form1, $WM_SYSCOMMAND, $SC_MOVE + $HTCAPTION, 0)
Case $Button2
ExitLoop
EndSwitch
WEnd
GUIDelete()
Func _ReduceMemory($i_PID = -1)
If $i_PID <> -1 Then
Local $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $i_PID)
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', $ai_Handle)
DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle)
Else
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
EndIf
Return $ai_Return
EndFunc ;==>_ReduceMemory
就这么一段代码Func _ReduceMemory($i_PID = -1),占用内存从11.28M 降到几百K,太神奇了。 回复 4# lixiaolong
谢谢了,这个函数数做什么的呢????? 回复iori2882
lixiaolong 发表于 2012-4-26 20:09 http://www.autoitx.com/images/common/back.gif
_ReduceMemory(),这个函数犀利 回复 6# iori2882
它的作用是释放指定进程的内存.
http://www.autoitx.com/forum.php?mod=viewthread&tid=245&highlight=%C4%DA%B4%E6%CA%CD%B7%C5
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682606(v=vs.85).aspx 回复iori2882
它的作用是释放指定进程的内存.
lixiaolong 发表于 2012-4-27 10:03 http://www.autoitx.com/images/common/back.gif
谢谢 知道了 这代码早有了...... GUI控件和控件样式越多,占用的内存越大。如果想解决加上内存释放函数就行了 回复 4# lixiaolong
这么好的函数,我最近才开始使用,没想到这木的犀利啊! 本帖最后由 netegg 于 2012-5-5 09:18 编辑
据说不是释放内存,apiex里有相同的函数,不过名称为emptyworkingset,字面意思是清空工作集,具体的用处可以看看msdn,曾经听说是转移到页面文件了 这段代码我一直都在使用的,但是这个贴子我今天才看到,要不然就是我得加分了 释放了对程序效率有影响没?
页:
[1]
2