跟踪线程内存和CPU消耗 [英] Tracking threads memory and CPU consumption

查看:165
本文介绍了跟踪线程内存和CPU消耗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Linux应用程序,该应用程序观察其他应用程序并跟踪资源消耗.我正在计划使用Java,但是编程语言对我而言并不重要.目标很重要,因此我可以切换到其他技术或使用模块.我的应用程序将任何选定的第三方应用程序作为子进程运行.大多数情况下,子软件会解决一些算法,例如图形,字符串搜索等.观察程序会在结束工作时跟踪子资源.

I'm writing a Linux application which observes other applications and tracks consumption of resources . I'm planning work with Java, but programming language isn't important for me. The Goal is important, so I can switch to another technology or use modules. My application runs any selected third party application as child process. Mostly child software solves some algorithm like graphs, string search, etc. Observer program tracks child's resources while it ends the job.

如果子应用程序是多线程的,也许可以某种方式跟踪每个线程消耗多少资源?可以使用任何非分布式内存线程技术来编写应用程序:Java线程,Boost线程,POSIX线程,OpenMP等.

If child application is multi-threaded, maybe somehow is possible to track how much resources consumes each thread? Application could be written using any not distributive-memory threads technology: Java threads, Boost threads, POSIX threads, OpenMP, any other.

推荐答案

内存未分配给线程,通常在线程之间共享.这使得谈论线程的内存消耗通常是不可能的,至少是没有意义的.

Memory is not allocated to threads, and often shared across threads. This makes it generally impossible and at least meaningless to talk about the memory consumption of a thread.

一个示例可能是具有11个线程的程序; 1个创建对象,10个使用这些对象.大多数工作在这10个线程上完成,但是所有内存都在创建对象的一个​​线程上分配.现在,如何解释这一点?

An example could be a program with 11 threads; 1 creating objects and 10 using those objects. Most of the work is done on those 10 threads, but all memory was allocated on the one thread that created the objects. Now how does one account for that?

这篇关于跟踪线程内存和CPU消耗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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