找回密码
 加入
搜索
查看: 11270|回复: 16

[GUI管理] AU3 GUI窗口占用内存怎么这么大

 火.. [复制链接]
发表于 2012-4-26 08:34:12 | 显示全部楼层 |阅读模式
本帖最后由 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()
发表于 2012-4-26 08:35:52 | 显示全部楼层
做什么用的?
 楼主| 发表于 2012-4-26 09:26:46 | 显示全部楼层
做什么用的?
lxzan 发表于 2012-4-26 08:35

...就一个普通窗口,你复制代码运行下就知道了
发表于 2012-4-26 20:09:48 | 显示全部楼层
回复 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[0])
                DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $ai_Handle[0])
        Else
                Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
        EndIf

        Return $ai_Return[0]
EndFunc   ;==>_ReduceMemory

评分

参与人数 3金钱 +80 贡献 +4 收起 理由
haijie1223 + 30
iori2882 + 30 + 2 谢谢你
whitehead + 20 + 2

查看全部评分

发表于 2012-4-26 21:28:48 | 显示全部楼层
就这么一段代码Func _ReduceMemory($i_PID = -1),占用内存从11.28M 降到几百K,太神奇了。
 楼主| 发表于 2012-4-27 08:20:41 | 显示全部楼层
回复 4# lixiaolong

谢谢了,这个函数数做什么的呢?????
发表于 2012-4-27 08:28:36 | 显示全部楼层
回复  iori2882
lixiaolong 发表于 2012-4-26 20:09



     _ReduceMemory(),这个函数犀利
发表于 2012-4-27 10:03:21 | 显示全部楼层
 楼主| 发表于 2012-4-27 10:43:08 | 显示全部楼层
回复  iori2882

它的作用是释放指定进程的内存.
lixiaolong 发表于 2012-4-27 10:03


谢谢 知道了
发表于 2012-4-27 11:18:28 | 显示全部楼层
这代码早有了......
发表于 2012-5-5 04:32:35 | 显示全部楼层
GUI控件和控件样式越多,占用的内存越大。如果想解决加上内存释放函数就行了
发表于 2012-5-5 07:01:34 | 显示全部楼层
回复 4# lixiaolong
这么好的函数,我最近才开始使用,没想到这木的犀利啊!
发表于 2012-5-5 09:15:24 | 显示全部楼层
本帖最后由 netegg 于 2012-5-5 09:18 编辑

据说不是释放内存,apiex里有相同的函数,不过名称为emptyworkingset,字面意思是清空工作集,具体的用处可以看看msdn,曾经听说是转移到页面文件了

评分

参与人数 1金钱 +20 收起 理由
lixiaolong + 20

查看全部评分

发表于 2012-5-5 20:14:56 | 显示全部楼层
这段代码我一直都在使用的,但是这个贴子我今天才看到,要不然就是我得加分了
发表于 2012-5-6 00:59:04 | 显示全部楼层
释放了对程序效率有影响没?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-24 08:20 , Processed in 0.092430 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表