Lisp中的当前内存使用情况 [英] Current memory usage in Lisp
问题描述
我需要从Common Lisp程序中找出当前正在使用多少内存.
I need to find out, from within a Common Lisp program, how much memory is currently being used.
我了解没有一种可移植的方法(标准功能room
以文本形式将信息打印到标准输出中,而不是将其作为值返回),但是sb-kernel:dynamic-usage
在SBCL中工作.
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.
其他Common Lisp实现中有哪些等效项?还是有其他方法可以解决这个问题?
What are the equivalents in other Common Lisp implementations? Or is there another way to solve this problem I should be looking at?
推荐答案
它可能对您没有多大帮助,但无论如何:
It may not help you much, but anyway:
您可以捕获(房间)的输出并进行解析.
You can capture the output of (room) and parse it.
(with-output-to-string (*standard-output*)
(room))
上面返回的字符串为ROOM输出.
Above returns a string with the output of ROOM.
另外,通过对标准unix命令的外部调用(如果您在Unix上),可能有助于请求进程的内存大小.
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).
这篇关于Lisp中的当前内存使用情况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!