P534页
1、“在早期16的windows中,因为windows不能在物理内存中移动内存块,所以禁止使用GMEM_FIXED标志” ----是不是应该是FMEM_MOVEABLE
2、“在32位的Windows中,GMEM_FIXED标志很普通,这是因为它将返回一个虚拟地址,并且操作系统也能够通过更改页表来在物理内存中移动内存块”---GMEM_FIXED是不是也应该改为FMEM_MOVEABLE; “操作系统也能够通过更改页表来在物理内存中移动内存块”这句是不是也有点问题,因为MSDN上说,“In Win32, memory blocks are never moved in physical memory, but they can be moved within the default heap. ”

解决方案 »

  1.   

    应该没有问题,MSDN 上它举的一个例子也用 GMEM_FIXED 标志的:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_7zfp.asp
      

  2.   

    怎么没有人关注了呢
    《windows程序设计》关于剪贴板这一章里面好多东西说的都不是特别清楚,越和MSDN对着看越糊涂,翻译败笔!!
      

  3.   

    可以对照着和msdn比较一下
    当时看的时候也是稀里糊涂的
    楼主好细心:)
      

  4.   

    大部分翻译都是败笔!
    所以我们信MSDN!
      

  5.   

    没有错误。首先看16位系统,“推荐使用GMEM_MOVEABLE”,此时“允许Windows在虚拟内存中移动一个内存块。这不是说将在物理内存中移动内存块,只是应用程序用于读写这块内存的地址可以被变动。”...(1)再看32位系统,“应用程序的虚拟地址空间将会变得支离破碎。……您将希望内存是可移动的。”,这种情况下才用GMEM_MOVEABLE。就是说一般在win32是用GMEM_FIXED的。...(2)
    下面解答楼主的第一个疑问,因为“windows不能在物理内存中移动内存块”,所以用GMEM_MOVEABLE,这个就是(1)所指的内容。而第二个疑问,当然不能改成GMEM_MOVEABLE,因为根据MSDN的说法GMEM_MOVEABLE时分配的内存块并不是在物理内存中移动的。至于那句话跟MSDN也不矛盾,因为对象分别是GMEM_FIXED和GMEM_MOVEABLE,当然不矛盾。
    然后我谈谈我的理解。GMEM_FIXED跟GMEM_MOVEABLE的区别从字面上讲,是指返回的memory block首地址是否发生变化,不变的就是GMEM_FIXED,变的就是GMEM_MOVEABLE。前者执行GlobalAlloc的返回值就是pointer;后者只是一个handle,需要GlobalLock才能得到pointer,是可变的,当然“这个变化不是物理内存的变化”这一点我也不怎么理解,但MSDN就是这么说的,对硬件机制比较了解的大牛才能明白。
    最后附上英文原文,可以看到,翻译也是没有错误的:
    In the early 16-bit versions of Windows, the GMEM_FIXED flag was strongly discouraged because Windows could not move the block in physical memory. In the 32-bit versions of Windows, the GMEM_FIXED flag is normal because it returns a virtual address and the operating system can move the block in physical memory by altering the page table. When programming for the 16-bit versions of Windows, using the flag GMEM_MOVEABLE in GlobalAlloc was instead recommended. 
    ...
    The GMEM_MOVEABLE flag allows Windows to move a memory block in virtual memory. This doesn't necessarily mean that the memory block will be moved in physical memory, but the address that the application uses to read and write to the block can change. Although GMEM_MOVEABLE was the rule in 16-bit versions of Windows, it is generally less useful now. However, if your application frequently allocates, reallocates, and frees memory blocks of various sizes, the virtual address space of your application can become fragmented. Conceivably, you could run out of virtual memory addresses. If this is a potential problem, then you'll want to use movable memory, and here's how to do it...
      

  6.   

    GMEM_FIXED 在32位机子上已经没有用的了。它不能真正的做到GMEM_FIXED ,每次在使用前还得调用globallock()函数才能使用的
      

  7.   

    GMEM_FIXED不需要调用GlobalLock的!看MSDN!
      

  8.   

    to BASIC(小明):
     请问在哪里能够找到关于这个方面比较详细的资料
      

  9.   

    to canjian(奋斗,探求,不达目的誓不罢休!):
    我手头只有中、英2个CHM和源码zip + MSDN for VS6(有时也去MSDN网站)。我很佩服您看得如此仔细,我是在看了您的这个帖子后才去仔细又把2个版本对照读了读。上面是我的个人看法,我希望能有人深刻、完整的提出解答。因为我业余编了个小程序要分配内存,在网上找了很多建议才决定用GlobalAlloc GMEM_FIXED这个方法的,其实w2k后应该用HeapAlloc。所以从逻辑上讲,我还是相信书里面是对的。我在CCF编程版见过一些牛人讨论,什么AllocateUserPhysicalPages,什么MapUserPhysicalPages,什么AWE(Address Windowing Extensions),还好像有个《inside win2k》的书。我上面帖子的看法是抛砖引玉,希望有机会能对内存分配的问题理解的更深。
      

  10.   

    to BASIC(小明):
    能不能把英文的chm发一个给我,不胜感激
    [email protected]