首页 新闻 会员 周边 捐助

。NET是否限制程序使用的内存?

0
悬赏园豆:20 [已解决问题] 解决于 2008-01-03 22:21
<P><SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">最近我正在用C#2.0做一个程序,</SPAN></P> <P><SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">程序在初始化的时候需要读取一个比较大的静态数组(已经硬性写到代码中去了)他的具体大小我不知道,但是代码文件的大小&nbsp;1.2M。</SPAN></P> <P><SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">&nbsp;奇怪的是我自己的笔记本上可以正常运行(OS:Vista CPU:T5500,RAM:2G),在工作室的台式机上就抛出了一下异常(OS:XP CPU:AMD3600+,RAM:1G)</SPAN></P> <P><SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">System.TypeInitializationException: </SPAN><SPAN lang=ZH-CN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 宋体; mso-ascii-theme-font: minor-latin; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri">“</SPAN><SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">Zephyr.Strategy.StrategyPolicy.ZStrategyPolicyWarehouse</SPAN><SPAN lang=ZH-CN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 宋体; mso-ascii-theme-font: minor-latin; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri">”的类型初始值设定项引发异常。</SPAN><SPAN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"> ---&gt; System.InvalidProgramException: </SPAN><SPAN lang=ZH-CN style="FONT-SIZE: 11pt; LINE-HEIGHT: 115%; FONT-FAMILY: 宋体; mso-ascii-theme-font: minor-latin; mso-fareast-theme-font: minor-fareast; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi; mso-
问题补充: 系统并没有抛出“Out of Memory”
逖靖寒的主页 逖靖寒 | 菜鸟二级 | 园豆:265
提问于:2007-12-29 18:43
< >
分享
最佳答案
0
本身应该没有限制, 遵循系统的限制 在32位系统下, 内存被分为2个部分,系统和用户,默认2者最大是2GB,在Windows 2003 下,通过/3GB参数,可以使用用户内存变成3GB,系统1GB 你那个情况还不好说,挂上调试器看看吧,如果真的是使用过度了,应该会出现OutOfMemoryException 错误,你看看任务管理器里的资源消耗。 找了2篇关于内存的文章,你可以看看。希望有所帮助 http://msdn.microsoft.com/msdnmag/issues/06/11/CLRInsideOut/default.aspx?loc=zh http://msdn.microsoft.com/msdnmag/issues/06/12/CLRInsideOut/default.aspx?loc=zh#S2
G yc {Son of VB.NET} | 老鸟四级 |园豆:2006 | 2007-12-30 05:12
其他回答(2)
0
是的, 不知道你两台机器的内存相差多少?几十兆的数组里面的内容已经相当可观了, 默认可以使用 60%的内存, 32位系统中单个进程使用的最大内存2.4G, 当.net可用内存的使用率超过50%时,GC会启动回收任务. 根所你的错误信息来看似乎不是这方面的原因,跟踪一下看看吧.
沙加 | 园豆:3680 (老鸟四级) | 2007-12-29 20:48
0
你要找到引发类型初始化异常的内部异常。从你的内部异常类型来,应该不是内存的原因引起的。如果是内存的问题,你可以看看我这三篇: http://www.cnblogs.com/hjf1223/archive/2007/11/23/970434.html http://www.cnblogs.com/hjf1223/archive/2007/11/24/970841.html http://www.cnblogs.com/hjf1223/archive/2007/11/24/971019.html
阿不 | 园豆:665 (小虾三级) | 2007-12-30 14:16
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册