在C ++中工作的大图像加载错误 [英] Large image load error that do work in C++

查看:63
本文介绍了在C ++中工作的大图像加载错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ia ?? m写了一个使用FreeImage.DLL的小DLL(可以在
找到一个 http://www.codeproject.com/bitmap/graphicsuite.asp) 。

我还用C ++编写了一个小型控制台应用程序(非托管) )使用上面的

DLL。


现在应用程序和上面的DLLa一起成功加载了一个

TIF图像文件(62992 x 113386像素,霍夫曼RLE压缩,3200 x 3200

DPI分辨率,二进制彩色(每像素1位),磁盘大小为43.08 MB的文件

(45,169,042字节)。加载时应该消耗851.66 MB内存。


现在我写了一个简单的C#应用​​程序,使用相同的DLLa(即

用C,C ++编写)和C ++应用程序一样。

但是C#应用程序无法加载图像(FreeImage_Load()

返回null)。


C#应用程序本身占用大约8MB,加载的图像加载

需要851.66 MB,所以这意味着它应该不会超过860 MB的内存。\\ br
内存。 />
PC安装了4 GB RAM,WinXP Pro只看到3.25 GB。

我还设置了带有/ 3GB标志的Boot.ini并且我的C#应用​​程序很受欢迎使用

IMAGE_FILE_LARGE_ADDRESS_AWARE标志。

我不需要我的应用程序的3GB,但是到底是什么。


它看起来像是.NET中的一个错误


有谁可以告诉我如何解决这个问题?

-

谢谢

Sharon

Ia??m wrote a small DLL that used the FreeImage.DLL (that can be found at
http://www.codeproject.com/bitmap/graphicsuite.asp).
I also wrote a small console application in C++ (unmanaged) that uses the
DLL above.

Now the application, together with the above DLLa??s is successfully loading a
TIF image file (62992 x 113386 Pixels, Huffman RLE compression, 3200 x 3200
DPI resolution, binary colored (1 Bit Per Pixel), file on disk size 43.08 MB
(45,169,042 Bytes). It should consume 851.66 MB of memory when loaded).

Now I wrote a simple C# application that used that same DLLa??s (that are
written in C, C++) and that do the same thins as the C++ application.
But the C# application is failing to load the image (FreeImage_Load()
returns null).

The C# application itself is taking about 8MB and the loaded image loading
takes 851.66 MB, so it means that is should take no more then 860 MB of
memory all together.
The PC is installed with 4 GB RAM, and the WinXP Pro is only seeing 3.25 GB.
I also set the Boot.ini with /3GB flag and my C# application is liked with
the IMAGE_FILE_LARGE_ADDRESS_AWARE flag.
I do not the 3GB for my app is needed, but what the heck.

It looks to me like a bug in the .NET

Can anybody tell my how to solve that?
--
Thanks
Sharon

推荐答案

Sharon,


你能否展示非托管声明(以及所有支持的

结构,如有必要)和相应的管理声明你/ b $ b有吗?这听起来好像你没有正确编组。

-

- Nicholas Paldino [.NET / C#MVP]

- mv*@spam.guard.caspershouse.com


" Sharon" <嘘***** @ newsgroups.nospam>在消息中写道

新闻:5C ********************************** @ microsof t.com ...
Sharon,

Can you show the unmanaged declaration (along with all of the supporting
structures, if necessary) and the corresponding managed declarations you
have? It sounds like you arent marshaling something correctly.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sharon" <Sh*****@newsgroups.nospam> wrote in message
news:5C**********************************@microsof t.com...
我写了一个使用FreeImage.DLL的小DLL(可以在
找到一个 http://www.codeproject.com/bitmap/graphicsuite.asp) 。
我还写了一篇C ++中的小型控制台应用程序(非托管)使用上面的
DLL。
现在应用程序,连同上面的DLL'已成功加载
一个
TIF图像文件(62992 x 113386像素,霍夫曼RLE压缩,3200 x
3200
DPI分辨率,二进制彩色(每像素1位),磁盘大小为43.08的文件
MB
(45,169,042字节)。加载时应该消耗851.66 MB的内存。

现在我写了一个简单的C#应用​​程序,它使用了相同的DLL(用C语言编写, C ++)和C ++应用程序一样。
但是C#应用程序是无法加载图像(FreeImage_Load()
返回null)。

C#应用程序本身占用大约8MB,加载的图像加载需要851.66 MB,所以这意味着这应该不会超过860 MB的内存。
PC安装有4 GB RAM,而WinXP Pro只看到3.25
GB。
我还设置带有/ 3GB标志的Boot.ini,我的C#应用​​程序被IMAGE_FILE_LARGE_ADDRESS_AWARE标志所喜欢。
我不需要我的应用程序的3GB,但是到底是什么。
<它看起来像是.NET中的一个错误

任何人都可以告诉我如何解决这个问题吗?

-
谢谢
Sharon
I''m wrote a small DLL that used the FreeImage.DLL (that can be found at
http://www.codeproject.com/bitmap/graphicsuite.asp).
I also wrote a small console application in C++ (unmanaged) that uses the
DLL above.

Now the application, together with the above DLL''s is successfully loading
a
TIF image file (62992 x 113386 Pixels, Huffman RLE compression, 3200 x
3200
DPI resolution, binary colored (1 Bit Per Pixel), file on disk size 43.08
MB
(45,169,042 Bytes). It should consume 851.66 MB of memory when loaded).

Now I wrote a simple C# application that used that same DLL''s (that are
written in C, C++) and that do the same thins as the C++ application.
But the C# application is failing to load the image (FreeImage_Load()
returns null).

The C# application itself is taking about 8MB and the loaded image loading
takes 851.66 MB, so it means that is should take no more then 860 MB of
memory all together.
The PC is installed with 4 GB RAM, and the WinXP Pro is only seeing 3.25
GB.
I also set the Boot.ini with /3GB flag and my C# application is liked with
the IMAGE_FILE_LARGE_ADDRESS_AWARE flag.
I do not the 3GB for my app is needed, but what the heck.

It looks to me like a bug in the .NET

Can anybody tell my how to solve that?
--
Thanks
Sharon



你一直在这里以及其他NG和论坛上提出同样的问题。

好​​吧,我对不起,答案仍然是一样的。 3.25 GB,

以上的部分是由硬件组件,如磁盘适配器,视频适配器(你甚至提到你已经安装了两个)等等... ...有内存

映射到Windows的32位地址空间,这意味着操作系统

本身看到(并使用)内存,但它不可用于用户

软件,这就是为什么它没有出现。

除了切换到XP 64位之外,你无能为力br />
并希望你有一个系统可以重新映射

控制器内存。


我之前也告诉过你你不能指望有一个单一的有条件的

块800MB可用内存。在Win32进程中可用,这是由于数据和代码模块(DLL')的进程堆碎片造成的。

你现在尝试赢得什么''工作,只是因为通过创建一个C#

应用程序,您需要加载其他模块,如CLR模块,

BCL以及可能的Windows.Forms和Windows.Drawing模块结果

a可用于您的图像数据的较小(大)可用内存块,而不是您在简单的C ++控制台程序中可用的
(顺便说一下

不使用GDI +。)

再次,你有两个选择,用C ++编写所有代码(但不要使用

GDI +)或移动到64位操作系统。

Willy。


" Sharon" <嘘***** @ newsgroups.nospam>在消息中写道

新闻:5C ********************************** @ microsof t.com ...
You have been asking this same question here and in other NG''s and forums .
Well, I''m sorry, but the answer is still the same. The part above 3.25 GB,
is taken by the hardware components like Disk adapters, Video adapters (you
even mentioned that you have two of them installed) etc... that have memory
mapped into the 32 bit address space of Windows, that means that the OS
itself sees (and uses) the memory but it''s not available for "user"
software, that is why it doesn''t show up.
There is nothing you can do about this, other than switching to XP 64 bit
and hope that you have a System that makes it possible to remap the
controler memory.

I also told you before that you can''t expect to have a "single contigious
block of 800MB free memory" available in a Win32 process, this is due to the
process heap fragmentation by data and code modules (DLL''s).
What you are trying now won''t work, simply because by creating a C#
application you need to load additional modules like the CLR modules, the
BCL and probably Windows.Forms and Windows.Drawing modules which results in
a smaller (large) block of free memory available for your image data, than
you had available in your simple C++ console program (which by the way
doesn''t use GDI+).
Again, you have two options, write all of your code in C++ (but don''t use
GDI+) or move to a 64bit OS.
Willy.


"Sharon" <Sh*****@newsgroups.nospam> wrote in message
news:5C**********************************@microsof t.com...
Ia ?? m写了一个使用FreeImage.DLL的小DLL(可以在
找到一个 http://www.codeproject.com/bitmap/graphicsuite.asp) 。
我还写了一篇C ++中的小型控制台应用程序(非托管),使用上面的
DLL。
现在应用程序,连同上面的DLLa ?? s成功加载
TIF图像文件(62992 x 113386像素,霍夫曼RLE压缩,3200 x
3200
DPI分辨率,二进制彩色(每像素1位),磁盘大小为43.08的文件
MB
(45,169,042字节)。加载时应该消耗851.66 MB的内存。

现在我写了一个简单的C#应用​​程序,它使用了相同的DLLa(用C语言编写, C ++)和C ++应用程序一样。但是C#应用程序是失败的g加载图像(FreeImage_Load()
返回null)。

C#应用程序本身占用大约8MB,加载的图像加载需要851.66 MB,所以这意味着应该不要超过860 MB的内存。
PC安装有4 GB RAM,而WinXP Pro只能看到3.25
GB。
我也是使用/ 3GB标志设置Boot.ini并使用IMAGE_FILE_LARGE_ADDRESS_AWARE标志喜欢我的C#应用​​程序。
我不需要3GB的应用程序,但是到底是什么。

任何人都可以告诉我如何解决这个问题吗?

-
谢谢
Sharon
Ia??m wrote a small DLL that used the FreeImage.DLL (that can be found at
http://www.codeproject.com/bitmap/graphicsuite.asp).
I also wrote a small console application in C++ (unmanaged) that uses the
DLL above.

Now the application, together with the above DLLa??s is successfully
loading a
TIF image file (62992 x 113386 Pixels, Huffman RLE compression, 3200 x
3200
DPI resolution, binary colored (1 Bit Per Pixel), file on disk size 43.08
MB
(45,169,042 Bytes). It should consume 851.66 MB of memory when loaded).

Now I wrote a simple C# application that used that same DLLa??s (that are
written in C, C++) and that do the same thins as the C++ application.
But the C# application is failing to load the image (FreeImage_Load()
returns null).

The C# application itself is taking about 8MB and the loaded image loading
takes 851.66 MB, so it means that is should take no more then 860 MB of
memory all together.
The PC is installed with 4 GB RAM, and the WinXP Pro is only seeing 3.25
GB.
I also set the Boot.ini with /3GB flag and my C# application is liked with
the IMAGE_FILE_LARGE_ADDRESS_AWARE flag.
I do not the 3GB for my app is needed, but what the heck.

It looks to me like a bug in the .NET

Can anybody tell my how to solve that?
--
Thanks
Sharon



您好Sharon,


我还建议您尝试将代码迁移到64位操作系统(例如

Windows XP Professional 64位版本,如果有可能的话。

64位操作系统(目前支持32 GB RAM,理论上限为

16 TB RAM。这使得32位系统的2-3 GB限制相形见绌,这些限制很快成为日益复杂的软件应用程序的瓶颈。

32位应用程序无法支持许多客户的增长

内存要求。对于那些尚未达到极限的人来说(即使用高分辨率图像或大量仓库数据处理
),

资源需求大致呈指数级增长意味着他们将很快就会达到这些限制。所以我认为64位操作系统对你来说是一个更好的解决方案。


最好的问候,


Terry Fei [MSFT]

微软社区支持

安全! www.microsoft.com/security

(此帖子按原样提供,不作任何保证,并且不授予

权利。)
Hi Sharon,

I also suggest you can try to migration the code to 64bit OS(for example
Windows XP Professional 64-bit Edition), if it''s possible for you.
64bit OS(currently supports 32 GB RAM and has a theoretical limit of around
16 TB RAM. This dwarfs the 2-3 GB limits on 32-bit systems that are
rapidly becoming bottlenecks to increasingly complex software applications.
32-bit applications are not capable of supporting many customers'' growing
memory requirements. For those that haven''t reached the limit yet (i.e.
working with high-resolution images or large amounts of warehoused data),
roughly exponential growth in resource requirements means that they will
reach these limits soon. So I think 64bit OS is a better solution for you.

Best Regards,

Terry Fei[MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


这篇关于在C ++中工作的大图像加载错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆