• <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

            統計

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

            常用鏈接

            留言簿

            隨筆分類

            隨筆檔案

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            HeapAlloc GlobalAlloc new等內存分配的區別

            GlobalAlloc是標準內存管理函數,標準內存管理函數都是操作進程的默認堆,所以這個函數是從進程的默認堆中分配內存空間,分配的空間可以是可移動的也可以是不可移動的。可移動的內存是指Windows在需要的時候可以將這個內存移動到另外一個地址.

             

            關于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是堆管理函數,堆管理函數可以操作非默認堆(當然也可以操作默認堆),創建一個堆是用HeapCreate,這個函數返回一個堆句 柄,然后可以用在HeapAllock函數中,即從返回的這個堆中申請內存空間,HeapAllock申請的內存只能是不可以移動的.

            而new則是c++的標準函數,在Windows的VC++編譯器中,new在申請內存時最終調用的是GlabalAlloc,不過new還可以調用類的構造函數.

            Windows的內存管理除了標準內存管理函數和堆管理函數之外,還有更加底層的虛擬內存管理函數,VirtualAlloc就是一個虛擬內存管理函數.

             

            Personal Comprehension

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

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

            亚洲成色WWW久久网站| 国产午夜精品久久久久九九| 久久亚洲国产最新网站| 狠狠久久综合| 伊人色综合九久久天天蜜桃| 久久无码中文字幕东京热| 久久久久久人妻无码| 91精品国产91热久久久久福利| 欧美午夜精品久久久久久浪潮| 中文字幕人妻色偷偷久久| 久久精品一区二区| 2019久久久高清456| 94久久国产乱子伦精品免费| 久久久久久久女国产乱让韩| 久久国产高清一区二区三区| 久久久久成人精品无码中文字幕 | 久久精品人成免费| 91亚洲国产成人久久精品| 久久人妻少妇嫩草AV无码专区| 久久久久人妻一区精品果冻| 国产精品久久久久9999| 亚洲中文字幕无码久久综合网| 久久久久国产亚洲AV麻豆| 国产99精品久久| 久久久精品人妻一区二区三区四| 四虎影视久久久免费观看| 嫩草影院久久国产精品| 久久影院综合精品| 人妻少妇久久中文字幕一区二区 | 久久播电影网| 亚洲国产天堂久久综合网站| 高清免费久久午夜精品| 91精品国产9l久久久久| 久久99精品久久久久婷婷| 亚洲国产精品无码久久久蜜芽| 伊人久久大香线蕉综合影院首页| 亚洲欧美成人久久综合中文网| 久久夜色精品国产亚洲av| 久久丝袜精品中文字幕| 亚洲第一永久AV网站久久精品男人的天堂AV | 韩国免费A级毛片久久|