全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:4133
推到 Plurk!
推到 Facebook!

Release Memory 釋放記憶體

 
TATSU
版主


發表:50
回覆:135
積分:62
註冊:2003-01-16

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-04-01 02:05:04 IP:203.218.xxx.xxx 未訂閱
Windows 的程式只有在 minimize 情況下才會大量釋放(回吐??),我在網上找了一些資料,原來是可以用一個 API function 去釋放,不用手動去 minimize 主程式。    
  if Win32Platform = VER_PLATFORM_WIN32_NT then
  begin
    SetProcessWorkingSetSize(GetCurrentProcess, $FFFFFFFF, $FFFFFFFF) ;
    Sleep(100) ;
  end;
我曾經嘗試沒有加上 sleep(100) 或 Application.ProcessMessages,程式會突然關閉或一些不明的錯誤令程式中斷執行。其中找到一些文章,作者亦提議那些全日執行不關閉的程式每五至十分鐘執行這一段去釋放記憶體,不過 98, Me 應該是用不上。 The SetProcessWorkingSetSize function sets the minimum and maximum working set sizes for a specified process. The working set of a process is the set of memory pages currently visible to the process in physical RAM memory. These pages are resident and available for an application to use without triggering a page fault. The size of the working set of a process is specified in bytes. The minimum and maximum working set sizes affect the virtual memory paging behavior of a process.
BOOL SetProcessWorkingSetSize(        HANDLE hProcess,        // open handle to the process of interest
    DWORD dwMinimumWorkingSetSize,        // specifies minimum working set size
    DWORD dwMaximumWorkingSetSize         // specifies maximum working set size
   );        
Parameters hProcess An open handle to the process whose working set sizes will be set. Windows NT: The handle must have PROCESS_SET_QUOTA access rights. For more information, see Process Objects. dwMinimumWorkingSetSize Specifies a minimum working set size for the process. The virtual memory manager attempts to keep at least this much memory resident in the process whenever the process is active. If both dwMinimumWorkingSetSize and dwMaximumWorkingSetSize have the value 0xffffffff, the function temporarily trims the working set of the specified process to zero. This essentially swaps the process out of physical RAM memory. dwMaximumWorkingSetSize Specifies a maximum working set size for the process. The virtual memory manager attempts to keep no more than this much memory resident in the process whenever the process is active and memory is in short supply. If both dwMinimumWorkingSetSize and dwMaximumWorkingSetSize have the value 0xffffffff, the function temporarily trims the working set of the specified process to zero. This essentially swaps the process out of physical RAM memory.
發表人 - tatsu 於 2004/04/01 14:19:55
One2Free
一般會員


發表:26
回覆:28
積分:20
註冊:2004-05-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-08-05 23:10:40 IP:219.135.xxx.xxx 未訂閱
XP 下,程式退出时偶有出错!弹出系统错误窗: dwwin.exe - DLL 因为窗口站已关闭,应用程序初始化失败 并有另一错误窗: Runtime error 216 at 00457D74 请问怎解决?
系統時間:2024-06-29 15:29:06
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!