• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            春暖花開
            雪化了,花開了,春天來了
            posts - 149,comments - 125,trackbacks - 0

            前階段在調(diào)研mobile上的內(nèi)存釋放問題,根據(jù)大家的建議嘗試了一些,但是沒有什么效果。
            于是跑到MSDN上去問相關(guān)的問題,得到了一些解答。

            As far as I know, I don't think there is other way to meet your requirement.  Since each mobile application has 32M memory limitation, we have to do the performance manually, like deleting object which is not used and allocating Large Memory Blocks in Large memory Area.

            For more information:
            Windows CE .NET Advanced Memory Management
            How the Windows Mobile 5.0 Shell Handles Low Memory Situations

            我看了一部分,在How the Windows Mobile 5.0 Shell Handles Low Memory Situations中提到,

             

             

            Hibernate

            This is the amount of memory the shell tries to keep free at all times. If the amount of free memory falls below this value then the low memory check routine will try to free up memory. It will do this by first sending WM_HIBERNATE to all valid applications. When an application receives this message it should try to free as many resources as possible. When the low memory check routine runs again and the amount of free memory is still below the hibernate level then the shell will try to close the least recently used (LRU) application by sending a WM_CLOSE message. If the low memory check routine runs yet again and the amount of free memory is still below the hibernate level then the shell will call TerminateProcess on the LRU application that it last sent the WM_CLOSE message to.


            我對這段話的理解是:當(dāng)空閑內(nèi)存小于Hibernate時(shí),系統(tǒng)便會(huì)嘗試釋放內(nèi)存。首先他會(huì)向所有有效的程序發(fā)送WM_HIBERNATE。應(yīng)用程序收到該消息后,會(huì)盡量釋放資源來釋放內(nèi)存。如果還低于這個(gè)值的話,將發(fā)送WM_CLOSE消息給最近很少使用的程序。如果還低于該值的,就強(qiáng)行關(guān)閉該程序了。

            這個(gè)方法似乎有效,但是用戶再起來程序的話,還是一樣的效果,并不是達(dá)到了什么釋放內(nèi)存的效果。如何記錄最近很少使用的程序,這個(gè)是不是有什么方法獲得呢?

            就可以像系統(tǒng)提示的那樣,內(nèi)存不足,請釋放一些內(nèi)存。手工做一些比較好。

            也看了一些相近的程序的做法,似乎效果也沒有大家說的那么好。

            How the Windows Mobile 5.0 Shell Handles Low Memory Situations的最后,這樣寫的

            What can my Application do?

            The best thing your application can do when faced with a low memory situation is to play nicely with the rest of the device. 

            1、If your application receives a WM_HIBERNATE message free up any resources not absolutely required. 
            2、If you are planning on allocating a large amount of memory (or if a large allocation fails) you should call SHCloseApps, which will invoke the shell low memory check routine and will try to ensure that enough free memory exists. See below for an example:

            #define MIN_MEMORY_TO_RUN 2*1024*1024

            MEMORYSTATUS mst;

            mst.dwLength  
            = sizeof(MEMORYSTATUS);

            GlobalMemoryStatus(
            &mst);

            If (mst.dwAvailPhys 
            < MIN_MEMORY_TO_RUN)

            {

                
            // Try to free memory by asking Shell to shutdown apps

                
            if (!SHCloseApps(MIN_MEMORY_TO_RUN))

                
            {

                    
            // Handle the case where memory could not be freed

                    …


            專門查了一下SHCloseApps的用法
            原型:BOOL SHCloseApps(  DWORD dwMemSought);
            功能:
            This function tries to free up memory for an application. If necessary, the shell closes down other applications by sending dwMemSought);
            功能:
            This function tries to free up memory for an application. If necessary, the shell closes down other applications by sending WM_CLOSE messages.
            參數(shù):dwMemSought Specifies, in bytes, the amount of memory to be freed.

            通過了解dwMemSought Specifies, in bytes, the amount of memory to be freed.

            通過了解SHCloseApps,我們就明白了上面那段代碼什么意思了。

            看來,內(nèi)存釋放并不是真正意義上的內(nèi)存整理,看來我有的地方誤解了!
            posted on 2009-03-05 13:56 Sandy 閱讀(1283) 評論(2)  編輯 收藏 引用 所屬分類: windows學(xué)習(xí)

            FeedBack:
            # re: 關(guān)于mobile的內(nèi)存釋放
            2009-03-05 14:13 | 亨德列克
            高!  回復(fù)  更多評論
              
            # re: 關(guān)于mobile的內(nèi)存釋放[未登錄]
            2009-03-05 16:54 | foxriver
            PC上有個(gè)類似的函數(shù)HeapCompact,初看很像內(nèi)存整理,仔細(xì)看也不是的。內(nèi)存整理牽涉的操作太多,操作系統(tǒng)也不好辦。  回復(fù)  更多評論
              
            中文字幕乱码久久午夜| 蜜臀av性久久久久蜜臀aⅴ| 久久久久女人精品毛片| 久久九九兔免费精品6| 久久综合九色欧美综合狠狠| 伊人久久大香线蕉精品| 久久国产精品成人免费 | 国产精品久久久久久影院| 久久WWW免费人成一看片| 久久婷婷色综合一区二区| 国产精品女同一区二区久久| 91精品国产综合久久香蕉| 国产99久久久国产精免费| 激情综合色综合久久综合| 精品人妻伦一二三区久久| 久久精品国产精品亚洲下载| 久久久久综合中文字幕| 亚洲午夜精品久久久久久app| 久久综合视频网| 久久久久久久人妻无码中文字幕爆 | .精品久久久麻豆国产精品| 国内精品九九久久久精品| 久久精品国产亚洲综合色| 亚洲一本综合久久| 日韩电影久久久被窝网| 欧美精品国产综合久久| 77777亚洲午夜久久多喷| 久久久久亚洲AV成人片| 2021国产成人精品久久| 亚洲国产精品狼友中文久久久 | 69国产成人综合久久精品| 狠狠久久综合| 久久狠狠爱亚洲综合影院| 久久久久四虎国产精品| 欧美久久久久久午夜精品| 亚洲日韩中文无码久久| 色综合久久88色综合天天| 久久午夜福利无码1000合集| 国产综合久久久久| 国产99久久久国产精品小说| 97精品国产91久久久久久|