内存与性能 [英] Memory vs. Performance

查看:86
本文介绍了内存与性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这在编程时一直在我的脑海中,所以我认为我应该先将其吐出来.

This has always been on my mind while programming, so I thought I'd spit it out before it actually gets to me.

我应该更担心什么?应用程序占用的内存或所需的性能.这样,我的意思是应该专注于为应用程序使用更少的内存并使用更高的性能(例如,通过数据库加载,并在使用后转储它),或者使用更低的性能并使用更多的内存(例如,缓存)

What should i be more worried about? The memory the application consumes, or the performance it takes. By this I mean should I be focused upon using less memory for of the application and using more performance (eg. loading via database, and dumping it after use), or using less performance and using more memory (eg. caching)

我的申请条件: -这是一个服务器应用程序,因此它不是要在台式机等上运行,我有6GB的ram,并且有四核.

My conditions for the application: - It's a server application, so it's not meant to be ran on desktops, etc, I have 6GB of ram, and I have a quad-core.

推荐答案

您的问题引起了很多类似禅宗佛教的回应.我希望做得更好.

Your question has drawn a lot of Zen Buddhism-like responses. I hope to do better.

您的内存限制很困难:如果超过此限制,即使有虚拟内存,您的应用程序也会爬网,您将成为一切的笑柄.

Your memory limit is hard: If you exceed it, even if there's virtual memory, your app will crawl and you'll be the laughing stock of all.

您的CPU时间是无限的:您的应用将花费所需的任何时间;希望它将足够并行,以使所有4个CPU在大多数情况下可以全蒸煮,直到应用程序完成.

Your CPU time is unlimited: Your app will take whatever time it needs; hopefully it will be sufficiently parallel that all 4 CPUs will be, for the most part, cooking with full steam until your app is finished.

许多计算机科学问题都有各种各样的解决方案,需要在内存与时间之间进行权衡取舍.因此,请慷慨地使用内存,直到您至少使用一半的内存为止(如果有帮助,不要浪费内存!),但是在有足够的内存剩余时停下来,您无需担心超出内存限制.限制,即使在特殊情况下或意外.

Many Computer Science problems have a variety of solutions with various tradeoffs of memory against time. So: Be generous with memory until you use at least about half of it (if that helps; don't waste memory for the heck of it!) but stop while there's enough memory left that you don't need to worry about exceeding the limit, even in exceptional cases or accidentally.

现在,您已经分配了内存资源,您可以尝试从代码中调整一些小的性能提升.但是,不要过度操心.

Now that you've allocated your memory resources, you can try to tweak some more small performance gains out of your code. But don't bother overdoing it.

完成.

P.S.如果它不能正确可靠地工作,那么前面的所有努力都是毫无用处的.时刻牢记这一点!

P.S. If it doesn't work correctly and reliably, all the preceding effort is worthless. Keep that in mind all the time!

祝你好运.

这篇关于内存与性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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