Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 80703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:20:39+00:00 2026-05-10T21:20:39+00:00

I have a class with the following member functions: /// caller pid virtual pid_t

  • 0

I have a class with the following member functions:

 /// caller pid virtual pid_t Pid() const = 0;   /// physical memory size in KB virtual uint64_t Size() const = 0;    /// resident memory for this process virtual uint64_t Rss() const = 0;   /// cpu used by this process virtual double PercentCpu() const = 0;   /// memory used by this process virtual double PercentMemory() const = 0;   /// number of threads in this process virtual int32_t Lwps() const = 0;   

This class’ duty is to return process information about caller. Physical memory size can easily determined by a sysctl call, and pid is trivial, but the remaining calls have eluded me, aside from invoking a popen on ps or top and parsing the output – which isn’t acceptable. Any help would be greatly appreciated.

Requirements:
Compiles on g++ 4.0
No obj-c
OSX 10.5

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:20:39+00:00Added an answer on May 10, 2026 at 9:20 pm

    Process info comes from pidinfo:

    cristi:~ diciu$ grep proc_pidinfo /usr/include/libproc.h  int proc_pidinfo(int pid, int flavor, uint64_t arg,  void *buffer, int buffersize); 

    cpu load comes from host_statistics:

    cristi:~ diciu$ grep -r host_statistics /usr/include/  /usr/include/mach/host_info.h:/* host_statistics() */  /usr/include/mach/mach_host.defs:routine host_statistics(  /usr/include/mach/mach_host.h:/* Routine host_statistics */  /usr/include/mach/mach_host.h:kern_return_t host_statistics 

    For more details, check out sources for top and lsof, they are open source (you need to register as an Apple developer but that’s free of charge):

    https://opensource.apple.com/source/top/top-111.20.1/libtop.c.auto.html

    Later edit: All these interfaces are version specific, so you need to take that into account when writing production code (libproc.h):

    /*  * This header file contains private interfaces to obtain process information.  * These interfaces are subject to change in future releases.  */ 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class in C++ with the following member: map< someEnum, vector<SomeObject*>* >
I have the following members defined in a class that I'm trying to deserialise:
I have a class with following description: public class Customer { public ISet<Client> Contacts
I have the following class public class Car { public Name {get; set;} }
I have the following class which uses BinaryReader internally and implements IDisposable. class DisposableClass
I have the following class: public abstract class AbstractParent { static String method() {
I have the following class [XmlRoot(ElementName= webSites)] //No capital w at the beginning public
I have the following class structure FlowerDAO with the fields (mapped using Hibernate): id
I have the following class in my C# .NET 3.5 win forms app: class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.