Lisp 当前内存使用情况

发布于 2024-10-02 13:04:12 字数 220 浏览 0 评论 0原文

我需要从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蔚蓝源自深海 2024-10-09 13:04:12

它可能对您没有多大帮助,但无论如何:

您可以捕获 (room) 的输出并解析它。

(with-output-to-string (*standard-output*)
  (room))

上面返回一个带有 ROOM 输出的字符串。

此外,它可能有助于通过外部调用标准 unix 命令(如果您使用的是 Unix)来请求进程的内存大小。

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))

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).

只想待在家 2024-10-09 13:04:12

对于几乎每个实现都支持但方式不同(因为它不在 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. :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文