在Lua中存储进程 [英] memory of a process in Lua

查看:215
本文介绍了在Lua中存储进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取Lua中任何进程的内存?

How can I get the meomory of any Process in Lua?

卢阿(Lua)有可能吗?是否可以使用C#,但我不确定.

Is it possible in Lua? Is C# it is possible but I am not sure.

在C#中,我们可以使用PerformanceCounter类获取

In C# we can use PerformanceCounter class to get the

PerformanceCounter WorkingSetMemoryCounter = new PerformanceCounter("Process",
    "Working Set", ReqProcess.ProcessName);

在Lua中这相当于什么?

What is equivalent of this in Lua?

假设IE(Internet Explorer)正在运行5个进程.如何获取这些进程的列表?

Suppose there are 5 process of IE (Internet Explorer) running . How to get a List of those process?

推荐答案

要详细说明其他人所说的话,Lua是一种用于嵌入的脚本语言.这意味着它在另一个应用程序内 内运行.

To elaborate on what others have said, Lua is a scripting language designed for embedding. That means that it runs inside another application.

Lua.exe是一种这样的应用程序.但这不是可以编写Lua脚本的唯一应用程序.

Lua.exe is one such application. But it is not the only application that Lua scripts can be written to be executed on.

在Lua脚本中,您可以完全且仅 访问周围应用程序环境所允许的内容.如果应用程序未明确允许您访问文件"或操作系统"之类的内容,那么您将无法访问它们.期间.

When within a Lua script, you have access to exactly and only what the surrounding application environment allows. If the application does not explicitly allow you to access things like "files" or "the operating system", then you don't get to access them. Period.

Lua的标准库(应用程序可以禁止脚本使用.Lua.exe允许它,但是有些嵌入式环境不允许),它很小.它没有提供很多便利设施,这使得Lua非常适合嵌入式环境:小型标准库意味着较小的可执行文件.这就是为什么您在移动应用程序中看到的Lua比Python多得多的原因.另外,标准库是跨平台的,因此它不能访问特定于平台的库.

Lua's standard library (which an application can forbid scripts to use. Lua.exe allows it, but there are some embedded environments that do not) is very small. It doesn't offer a lot of amenities, which make Lua ideal for embedded environments: small standard libraries mean smaller executables. Which is why you see a lot more Lua in mobile applications than, say, Python. Also, the standard library is cross-platform, so it does not access platform-specific libraries.

模块,用户编写的程序(在Lua或C/C ++中)可以加载到Lua.exe的环境中.这样的模块可以使您的Lua脚本访问诸如进程"之类的东西,该进程占用的内存等.但是,如果您无权访问此类模块,那么您就不会从Lua脚本中获取该信息.

Modules, user-written programs (either in Lua or C/C++) can be loaded into Lua.exe's environment. Such a module could give your Lua script access to things like "processes", how much memory the process is taking, and so forth. But if you do not have access to such a module, then you're not getting that info from within a Lua script.

您最能做的就是获取此特定Lua环境直接分配和使用的内存大小,如@lhf所说:collectgarbage "count".

The most you are going to be able to do is get the size of the memory that this particular Lua environment is directly allocating and using, as @lhf said: collectgarbage "count".

这篇关于在Lua中存储进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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