如何解决Delphi内存不足错误? [英] How resolve Delphi Out Of Memory Error?

查看:1943
本文介绍了如何解决Delphi内存不足错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Delphi XE2项目来处理大量的计算。

在我的项目中,我共有1290个数字编辑,340 标签的数量,330 面板的数量,16个 TabSheet 。对于每个编辑,有 OnChange OnDblClick OnEnter OnExit 事件。



我必须处理总共1034个变量的数字。我刚刚设计了 Form ,而不是添加这些计算逻辑。现在我的 .pas文件成为 62.5MB 具有 1815057行 .dfm文件成为 1.98 MB 拥有 65540行



我正在使用 Delphi XE2 Windows XP Professional SP3 32Bit 下编译项目,但我正在错误为 ** [DCC致命错误] Unit1.pas(1815058):F2046内存不足**



我也尝试使用 Delphi XE5 下的 Windows 8 Enterprise 64Bit ,这里也是,我遇到了同样的问题。



我没有添加完整的计算逻辑,使用1034变量数,如果我添加他们至少将 4200行添加到 .pas文件中。

解决方案

你的整个方法是有缺陷的。编译器根本无法处理您提供的文件大小。一个180万行的pascal源文件是可笑的。 2MB .dfm文件是不切实际的。



看来,您将所有可能的选项编码为单独的控件和变量。您没有手工编写代码,但是在Excel中使用预处理步骤完成。



解决方案不是在编译时扩展所有选项时间。解决方案是编写应用程序,以便它可以在运行时显示不同的选项。所以,你有30个不同的变量,你可能创建了30个不同的标签控件和30个不同的编辑控件。正确的做法是创建一个标签和一个编辑控件。然后在运行时,根据用户的选择,更改标签的标题和编辑控件的内容。



不要为每个可能的您需要存储的价值。使用数组和字典。



在高层次上,您需要采用Excel预处理步骤中包含的逻辑,并将其转换为运行时Delphi代码。


I am having one Delphi XE2 project to handle large numbers of calculations.
In my project i am having total 1290 Numbers of Edit, 340 Numbers of Label, 330 Numbers of Panel, 16 Numbers of TabSheet. For each and every Edit, there is OnChange, OnDblClick, OnEnter and OnExit events.

I have to handle total 1034 Numbers of Variable. I have just designed the Form and not added those calculation logic. Now my .pas file becomes 62.5MB having 1815057 Lines and .dfm file becomes 1.98 MB having 65540 Lines.

I am trying to compile the project using Delphi XE2 under Windows XP Professional SP3 32Bit, but I am getting error as **[DCC Fatal Error] Unit1.pas(1815058): F2046 Out of memory**.

I have also tried to compile it using Delphi XE5 under Windows 8 Enterprise 64Bit, here is also, I am getting the same problem.

I have not added the complete calculation logic using 1034 Numbers of variables, if I add them , at least 4200 Lines will be added to the .pas file.

解决方案

Your entire approach is flawed. The compiler simply cannot handle the size of file that you present it. A 1.8 million line pascal source file is ridiculous. A 2MB .dfm file is impractical.

It appears that you have coded all possible options as separate controls and variables. You've not written the code by hand, but have done so using a pre-processing step, in Excel.

The solution is not to expand all the options at compile time. The solution is to write the application so that it can present the different options at run time. So, where you have 30 different variables, you've probably created 30 different label controls, and 30 different edit controls. The correct approach is to create one label and one edit control. Then at run time, depending on the user's option, change the caption of the label, and the content of the edit control.

Don't create one variable for every possible value that you need to store. Use arrays and or dictionaries.

At a high level, you need to take the logic that is contained in your Excel pre-processing step and convert it into run time Delphi code.

这篇关于如何解决Delphi内存不足错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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