软件将使用内存,这并不奇怪,但如何将此使用量保持最小,与程序的大小相比呢?
Best example I think would be Firefox. Some users have experienced it, others haven t, but it s pretty safe to say that all the previous versions of Firefox used much more memory then the current version. Yet still, functionality expands and options are added. I d expect the memory usage to go up as extra options and such stuff gets added.
换句话说,必须有方法来确保您的程序不会耗尽计算机的内存。
因此,我将这转化为一个“最佳实践”问题,询问您们所有人的小技巧和微调,可让您的程序用比通常更少的CPU执行其功能。还要了解哪些是一定要避免的。
A little side-question here: I came accross something in a book about C#. Apparently, when coding an Enum, it s possible to set the size of the index of this Enum. With large Enum s, you should let the compiler handle it I guess, but for an Enum which only holds like 2 or 3 items, you can do this:
public enum HTMLTYPE : sbyte
{
HTML401,XHTML10,XHTML11
}
For those of you who don t know why, apparently the amount of memory reserved for the index of any Enum is automatically set to an integer in C#. So in other words, that amount of memory is going to be reserved. But when defining so little things in your Enum, an integer is a waste of space. The book claimed that this could cut down the amount of memory used by the program. I m wondering if this is true.
编辑:确实,它应该是记忆。我改了所有的条目。