• <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>
            <2009年9月>
            303112345
            6789101112
            13141516171819
            20212223242526
            27282930123
            45678910

            統(tǒng)計

            • 隨筆 - 21
            • 文章 - 0
            • 評論 - 2
            • 引用 - 0

            常用鏈接

            留言簿

            隨筆分類

            隨筆檔案

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            HeapAlloc GlobalAlloc new等內(nèi)存分配的區(qū)別

            GlobalAlloc是標(biāo)準(zhǔn)內(nèi)存管理函數(shù),標(biāo)準(zhǔn)內(nèi)存管理函數(shù)都是操作進程的默認(rèn)堆,所以這個函數(shù)是從進程的默認(rèn)堆中分配內(nèi)存空間,分配的空間可以是可移動的也可以是不可移動的。可移動的內(nèi)存是指Windows在需要的時候可以將這個內(nèi)存移動到另外一個地址.

             

            關(guān)于GlobalAlloc and LocalAlloc,from MSDN  
               
              The global and local functions supported for porting from 16-bit code, or maintaining source code compatibility with 16-bit Windows. The global and local functions are slower   than other memory management functions and do not provide as many features. Therefore,  new   applications should use the heap functions.However, the global functions are still used with DDE and the clipboard functions.  
               
              Windows memory management does not provide a separate local heap and global heap, as 16-bit Windows does. As a result, there is no difference between the memory objects allocated by the GlobalAlloc and LocalAlloc functions. In addition, the change from a 16-bit segmented memory model to a 32-bit virtual memory model has made some of the related global and local functions and their options unnecessary or meaningless. For example, there are no longer near and far pointers, because both local and global allocations return 32-bit virtual addresses.
             
              Memory objects allocated by GlobalAlloc and LocalAlloc are in private, committed pages with read/write access that cannot be accessed by other processes. Memory allocated by using GlobalAlloc with GMEM_DDESHARE is not actually shared globally as it is in 16-bit Windows. This value has no effect and is available only for compatibility. Applications requiring shared memory for other purposes must use file-mapping objects. Multiple processes can map a view of the same file-mapping object to provide named shared memory. For more information, see File Mapping.

            HeapAllock是堆管理函數(shù),堆管理函數(shù)可以操作非默認(rèn)堆(當(dāng)然也可以操作默認(rèn)堆),創(chuàng)建一個堆是用HeapCreate,這個函數(shù)返回一個堆句 柄,然后可以用在HeapAllock函數(shù)中,即從返回的這個堆中申請內(nèi)存空間,HeapAllock申請的內(nèi)存只能是不可以移動的.

            而new則是c++的標(biāo)準(zhǔn)函數(shù),在Windows的VC++編譯器中,new在申請內(nèi)存時最終調(diào)用的是GlabalAlloc,不過new還可以調(diào)用類的構(gòu)造函數(shù).

            Windows的內(nèi)存管理除了標(biāo)準(zhǔn)內(nèi)存管理函數(shù)和堆管理函數(shù)之外,還有更加底層的虛擬內(nèi)存管理函數(shù),VirtualAlloc就是一個虛擬內(nèi)存管理函數(shù).

             

            Personal Comprehension

            GlobalAlloc分配的內(nèi)存,還可以調(diào)用GlobalLock鎖定該內(nèi)存塊(該函數(shù)可以被多次調(diào)用),在我們沒有調(diào)用GlobalUnlock之 前,該內(nèi)存塊會一直保持有效(即使調(diào)用了GlobalFree函數(shù),但如果該內(nèi)存的鎖計數(shù)不為0,該內(nèi)存塊也不會被釋放掉,依然保持有效)!而如果只調(diào)用 一次delete,則使用new所分配的內(nèi)存就會被釋放掉.

            posted on 2009-09-06 21:50 ChinaPanda 閱讀(655) 評論(0)  編輯 收藏 引用 所屬分類: windows

            国产福利电影一区二区三区,免费久久久久久久精 | 色综合久久88色综合天天 | 久久久久这里只有精品| 一本色道久久综合狠狠躁篇| 久久久久久久波多野结衣高潮 | 奇米综合四色77777久久| 一级做a爰片久久毛片人呢| 欧美性大战久久久久久| 国产精品久久久久AV福利动漫| 91久久精品视频| 亚洲精品国产美女久久久| 国产精品日韩欧美久久综合| 久久久久高潮综合影院| 久久久久99精品成人片三人毛片 | 久久狠狠爱亚洲综合影院| 久久综合丁香激情久久| 婷婷久久久亚洲欧洲日产国码AV| 国产精品伊人久久伊人电影| 亚洲av日韩精品久久久久久a | 久久精品亚洲精品国产色婷| 手机看片久久高清国产日韩 | 7777精品久久久大香线蕉| 久久久黄片| 久久精品国产色蜜蜜麻豆| 97精品国产91久久久久久| 无码国内精品久久人妻蜜桃| 国内精品久久久久久久久电影网 | 久久亚洲精品无码AV红樱桃| 色综合合久久天天给综看| 久久久久久久国产免费看| 久久久久国产亚洲AV麻豆| 久久996热精品xxxx| 色综合色天天久久婷婷基地| 久久国产乱子伦精品免费强| 国产午夜精品理论片久久影视| 久久夜色精品国产噜噜噜亚洲AV| 久久精品国产99国产精品导航 | 欧美一级久久久久久久大片| 国产69精品久久久久9999| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 日韩精品久久久久久免费|