delphi 释放程序内存_优化您的Delphi程序的内存使用率

delphi 释放程序内存

When writing long-running applications - the kind of programs that will spend most of the day minimized to the taskbar or system tray, it can become important not to let the program 'run away' with memory usage.

在编写长期运行的应用程序时(这种类型的程序会在一天的大部分时间里最小化到任务栏或系统托盘中) ,重要的是不要让程序因内存使用而“失控”。

Learn how to clean up the memory used by your Delphi program using the SetProcessWorkingSetSize Windows API function.

了解如何使用SetProcessWorkingSetSize Windows API函数清理Delphi程序使用的内存。

Windows如何看待程序的内存使用情况? ( What Does Windows Think About Your Program's Memory Usage? )

windows taskbar manager

Take a look at the screenshot of the Windows Task Manager...

看一下Windows Task Manager的屏幕截图...

The two rightmost columns indicate CPU (time) usage and memory usage. If a process impacts on either of these severely, your system will slow down.

最右边的两列指示CPU(时间)使用率和内存使用率。 如果某个过程严重影响这两个过程中的任何一个,则系统将变慢。

The kind of thing that frequently impacts on CPU usage is a program that is looping (ask any programmer that has forgotten to put a "read next" statement in a file processing loop). Those sorts of problems are usually quite easily corrected.

经常影响CPU使用率的事情是正在循环的程序(询问所有忘记在文件处理循环中放入“ read next”语句的程序员)。 这类问题通常很容易纠正。

Memory usage, on the other hand, is not always apparent and needs to be managed more than corrected. Assume for example that a capture type program is running.

另一方面,内存使用并不总是很明显,需要进行更多的管理而不是更正。 例如,假设捕获类型程序正在运行。

This program is used right throughout the day, possibly for telephonic capture at a help desk, or for some other reason. It just doesn’t make sense to shut it down every twenty minutes and then start it up again. It’ll be used throughout the day, although at infrequent intervals.

该程序全天使用,可能用于在服务台进行电话捕获,或出于其他原因。 每隔二十分钟将其关闭然后重新启动就没有意义了。 它会全天使用,尽管不经常使用。

If that program relies on some heavy internal processing or has lots of artwork on its forms, sooner or later its memory usage is going to grow, leaving less memory for other more frequent processes, pushing up the paging activity, and ultimately slowing down the computer.

如果该程序依赖于繁重的内部处理或表单上包含大量图稿,则其内存使用迟早会增加,从而为其他更频繁的进程留出更少的内存,从而增加了分页活动,并最终降低了计算机的速度。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值