简体   繁体   English

64位库限制为4GB?

[英]64-bit library limited to 4GB?

I'm using an image manipulation library that throws an exception when I attempt to load images > 4GB in size. 我正在使用一个图像处理库,当我尝试加载大小为4GB的图像时抛出异常。 It claims to be 64bit, but wouldn't a 64bit library allow loading images larger than that? 它声称是64位,但64位库不允许加载大于此的图像吗? I think they recompiled their C libraries using a 64 bit memory model/compiler but still used unsigned integers and failed upgrade to use 64 bit types. 我认为他们使用64位内存模型/编译器重新编译了他们的C库,但仍使用无符号整数并且升级失败以使用64位类型。

Is that a reasonable conclusion? 这是一个合理的结论吗?

Edit - As an after-thought can OS memory become so fragemented that allocation of large chunks is no longer possible? 编辑 - 作为一个经过深思熟虑后,操作系统内存会变得如此分散,以至于不再可能分配大块? (It doesn't work right after a reboot either, but just wondering.) What about under .NET? (它在重新启动后也无法正常工作,但只是想知道。)在.NET下呢? Can the .NET managed memory become so fragmented that allocation of large chunks fails? .NET托管内存是否会变得如此碎片化以至于大块的分配失败了?

It's a reasonable suggestion, however the exact cause could be a number of things - for example what OS are you running, how much RAM / swap do you have? 这是一个合理的建议,但确切的原因可能是很多事情 - 例如你运行的操作系统,你有多少内存/交换? The application/OS may not over-commit virtual memory so you'll need 4GB (or more) of free RAM to open the image. 应用程序/操作系统可能不会过度提交虚拟内存,因此您需要4GB(或更多)空闲RAM才能打开映像。

Out of interest does it seem to be a definite stop at the 4GB boundary - ie does a 3.99GB image succeed, but a 4GB one fail - you say it does which would suggest a definite use of a 32bit size in the libraries data structures. 出于兴趣,它似乎是4GB边界的明确停止 - 即3.99GB图像成功,但4GB失败 - 你说它确实表明在库数据结构中明确使用32位大小。

Update 更新

With regards your second question - not really. 关于你的第二个问题 - 不是真的。 Pretty much all modern OS's use virtual memory, so each process gets it's own contiguous address space. 几乎所有现代操作系统都使用虚拟内存,因此每个进程都会获得自己的连续地址空间。 A single contiguous region in a processes' address space doesn't need to be backed by contiguous physical RAM, it can be made up of a number of separate physical areas of RAM made to look like they are contiguous; 进程地址空间中的单个连续区域不需要由连续的物理RAM支持,它可以由许多独立的RAM物理区域组成,看起来像是连续的; so the OS doesn't need to have a single 4GB chunk of RAM free to give your application a 4GB chunk. 所以操作系统不需要有一个4GB的RAM空闲空间来为你的应用程序提供4GB的块。

It's possible that an application could fragment it's virtual address space such that there isn't room for a contiguous 4GB region, but considering the size of a 64-bit address space it's probably highly unlikely in your scenario. 应用程序可能会碎片化它的虚拟地址空间,使得没有连续4GB区域的空间,但考虑到64位地址空间的大小,它可能在您的场景中不太可能。

是的,除非二进制文件格式本身限制图像的大小。

To answer your follow up, I recently read this article and found it interesting. 为了回答你的跟进,我最近阅读了这篇文章并发现它很有趣。

And yes, .NET can have problems with memory fragmentation . 是的,.NET可能存在内存碎片问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM