Lisp 当前内存使用情况
我需要从 Common Lisp 程序中找出当前使用了多少内存。
我知道没有可移植的方法(标准函数 room
以文本形式将信息打印到标准输出,而不是将其作为值返回),但是 sb-kernel:dynamic -usage
适用于 SBCL。
其他 Common Lisp 实现中的等价物是什么?或者还有其他方法可以解决我应该考虑的这个问题吗?
I need to find out, from within a Common Lisp program, how much memory is currently being used.
I'm given to understand there is no portable method (the standard function room
prints the information to standard output in text form instead of returning it as a value), but sb-kernel:dynamic-usage
works in SBCL.
What are the equivalents in other Common Lisp implementations? Or is there another way to solve this problem I should be looking at?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它可能对您没有多大帮助,但无论如何:
您可以捕获 (room) 的输出并解析它。
上面返回一个带有 ROOM 输出的字符串。
此外,它可能有助于通过外部调用标准 unix 命令(如果您使用的是 Unix)来请求进程的内存大小。
It may not help you much, but anyway:
You can capture the output of (room) and parse it.
Above returns a string with the output of ROOM.
Additionally it may help to request the memory size of the process via an external call to a standard unix command (if you are on Unix).
对于几乎每个实现都支持但方式不同(因为它不在 CL 中)的事物,一种常见的方法是创建一个名为 微不足道-无论如何。
如果您启动了像
trivial-memory
这样的包,并提供了第一个实现,我相信我们可以让每个人在短时间内为他们自己最喜欢的 Lisp 编译器贡献该功能。 :-)For things which virtually every implementation supports, but not in the same way (because it's not in CL), one common approach is to make a library called trivial-whatever.
If you started a package like
trivial-memory
, and supplied the first implementation, I'm sure we could get everybody to contribute the function for their own favorite Lisp compiler in short order. :-)