473,806 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get statistics about memory usage ?

Hi,

Inside a program, I need to get some statistics about memory usage.
I actually need figures given by the "ps -o vsr,rss" command.

For the moment, I make a popen("ps...") followed of a scanf on what it
displays. It is a little complicated, and that distorts measurements.
Is there a better way?

I have tried "getrusage( )". However values returned are not really
relevant for my needs.

I also looked at "mallinfo() ", without success.
First, I do not know what is that a "block" (which size ?). Then, that does
not count the stack size and the code size, just the malloc.
(By the way, it's more or less a C++ code. So, are the "new" counted in
mallinfo() ?)

Then, how can my program know its "resident set size" and especially its
"virtual memory size"?

Thanks.
Christophe
Dec 2 '05
26 19147
Jordan Abel wrote:
On 2005-12-02, Joe Estock <je*****@NOSPAM nutextonline.co m> wrote:
Kenny McCormack wrote:
[usual crap]

You're still alive Kenny? I thought someone would have killfiled you by now.

You know - i don't think you understand how a "killfile" works. It
blocks him from being seen by the person who sets the killfile entry,
unless someone else [you] responds to him. If you want him gone, _you_
have to "killfile" him [i'm not sure how thunderbird 1.0.9 does it, but
surely there's some way to ignore or mark-as-read based on from address]


Forgot to add this bit of information to my previous post, but FWIW in
Thunderbird you add what's called a "Message Filter". Tools->Message
Filters->New.
Dec 3 '05 #21
Kenny McCormack said:
In article <dm**********@e nyo.uwa.edu.au> ,
Chris McDonald <ch***@csse.uwa .edu.au> wrote:

It's very interesting to note that the first reply to this topic was
someone quickly highlighting how off-topic the topic was. The OP has
since moved on to comp.unix.progr ammer, and received a helpful reply.
That shows that we did the right thing.

"Excuse me, I'd like to buy a stamp."
"Ah, we're a greengrocer; we don't sell stamps here. Lettuce, yes, letters,
no. You want the post office. It's just over the road. See the sign?"
"Oh! Thank you very much..."

The OP gets his stamp much quicker that way. And it'll be a good stamp, not
just a potato-cut.
Since then, we've seen about a dozen articles, some from old hands,
continuing a debate about exactly what is, and what is not, a
Linux-specific feature.


It's what we do. We're not allowed to talk about anything substantive, so
this is what we do.


Wrong on several counts:

1) there's loads of substantive stuff to discuss here; the fact that you
don't realise that it's substantive is irrelevant;
2) you can talk about whatever you like, and we ask only that you find a
newsgroup where that subject is topical;
3) whilst we do occasionally have discussions emanating from off-topic
questions, that isn't really "what we do" - what we do is C, and some of
the folks here are extremely good at it.

You appear to delight in parading your ignorance of these facts, so that all
the world may know that you cannot grasp a simple classification concept
such as topicality.

You also seem to think that the opinions you express on comp.lang.c are
worth as much as anyone else's. Well, they will be, when (and only when)
you demonstrate that your knowledge of C is sufficiently encyclopaedic that
it becomes a good use of people's time to put up with your drivel for the
sake of your expertise. Until then, you will always remain mere background
noise.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Dec 3 '05 #22
On Sat, 3 Dec 2005 01:33:08 +0000 (UTC), in comp.lang.c , Chris
McDonald <ch***@csse.uwa .edu.au> wrote:
Since then, we've seen about a dozen articles, some from old hands,
continuing a debate about exactly what is, and what is not, a
Linux-specific feature.


You're right, we shold probably have shut up. Occasionally however,
misinformation supplied here is sufficiently annoying or misleading to
cause responses even from those who should know better.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt >

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Dec 3 '05 #23
In article <dm**********@n wrdmz02.dmz.ncs .ea.ibs-infra.bt.com>,
Richard Heathfield <in*****@invali d.invalid> wrote:
(the usual crap)
....
You also seem to think that the opinions you express on comp.lang.c are
worth as much as anyone else's. Well, they will be, when (and only when)
you demonstrate that your knowledge of C is sufficiently encyclopaedic that
it becomes a good use of people's time to put up with your drivel for the
sake of your expertise.
I believe the relevant phrase here is: PKB
Until then, you will always remain mere background noise.


Blah, blah, blah.

Dec 3 '05 #24
Richard Heathfield wrote:
Kenny McCormack said:

In article <dm**********@e nyo.uwa.edu.au> ,
Chris McDonald <ch***@csse.uwa .edu.au> wrote:
It's very interesting to note that the first reply to this topic was
someone quickly highlighting how off-topic the topic was. The OP has
since moved on to comp.unix.progr ammer, and received a helpful reply.

That shows that we did the right thing.

"Excuse me, I'd like to buy a stamp."
"Ah, we're a greengrocer; we don't sell stamps here. Lettuce, yes, letters,
no. You want the post office. It's just over the road. See the sign?"
"Oh! Thank you very much..."

The OP gets his stamp much quicker that way. And it'll be a good stamp, not
just a potato-cut.
I agree completely. Why would we tell someone to use their hand to drive
in a nail when we can point them to a hammer instead. I agree that some
replys are a bit cocky in this regard, however in my experience it does
nothing more than further encourage the OP to seek help in another (more
appropriate) newsgroup as opposed to this one.

Since then, we've seen about a dozen articles, some from old hands,
continuing a debate about exactly what is, and what is not, a
Linux-specific feature.
It's what we do. We're not allowed to talk about anything substantive, so
this is what we do.

Wrong on several counts:

1) there's loads of substantive stuff to discuss here; the fact that you
don't realise that it's substantive is irrelevant;
2) you can talk about whatever you like, and we ask only that you find a
newsgroup where that subject is topical;
3) whilst we do occasionally have discussions emanating from off-topic
questions, that isn't really "what we do" - what we do is C, and some of
the folks here are extremely good at it.


In addition to the above, we sometimes talk about popular extensions to
the c langauge that are resident in nearly all implementations of the
standard c library and that in itself is still on topic IMHO so long as
it's clear that it's not an official part of the standard. This
distinction is very important because newcomers to the group may think
that the extension we are discussing is part of the actual c standard
and then we grow a new breed of misguided programmers. To further prove
this point, I used to work with a few guys who thought that MFC
(Microsoft Foundation Classes) were in fact part of the standard c
library as outlined by the C89 standard and they would argue with me
over it for hours at a time if I let them.

You appear to delight in parading your ignorance of these facts, so that all
the world may know that you cannot grasp a simple classification concept
such as topicality.
I've noticed this more and more over the past few weeks. Kenny seems to
like disrupting posts in order to delight himself (or so it would seem
since none of the regulars seem to pay him any mind). He always whines
and complains that we're strictly on topic here and that is not always
the case. We don't always adhere to the rules when replying to a message
(my reply being case and point), however nobody minds. Even when a post
does not adhere to the rules here, we prefix the message with the
characters [OT] which allows others to filter out the junk from the juice.

You also seem to think that the opinions you express on comp.lang.c are
worth as much as anyone else's. Well, they will be, when (and only when)
you demonstrate that your knowledge of C is sufficiently encyclopaedic that
it becomes a good use of people's time to put up with your drivel for the
sake of your expertise. Until then, you will always remain mere background
noise.


Well put and I completely agree. Perhaps Kenny will one day grow up and
learn that this newsgroup is not a battleground for showing off your
leet typing skills, rather it is an invaluable tool to those of us who
actually know c and need a little help now and again. Of course I
personaly feel that by the time this happens earth will no longer be
populated with c programmers as we will all have established life on
another planet that is not infested with trolls such as Kenny. Again,
that's just my personal view on things.

That's just my two cents.

Joe
Dec 3 '05 #25
Richard Heathfield wrote:
Kenny McCormack said:
In article <dm**********@e nyo.uwa.edu.au> ,
Chris McDonald <ch***@csse.uwa .edu.au> wrote:

It's very interesting to note that the first reply to this topic was
someone quickly highlighting how off-topic the topic was. The OP has since moved on to comp.unix.progr ammer, and received a helpful reply.

That shows that we did the right thing.

"Excuse me, I'd like to buy a stamp."
"Ah, we're a greengrocer; we don't sell stamps here. Lettuce, yes, letters, no. You want the post office. It's just over the road. See the sign?" "Oh! Thank you very much..."

The OP gets his stamp much quicker that way. And it'll be a good stamp, not just a potato-cut.
I agree completely. Why would we tell someone to use their hand to
drive
in a nail when we can point them to a hammer instead. I agree that
some
replys are a bit cocky in this regard, however in my experience it
does
nothing more than further encourage the OP to seek help in another
(more
appropriate) newsgroup as opposed to this one.


Since then, we've seen about a dozen articles, some from old hands,
continuing a debate about exactly what is, and what is not, a
Linux-specific feature.

It's what we do. We're not allowed to talk about anything substantive, so this is what we do.
Wrong on several counts:

1) there's loads of substantive stuff to discuss here; the fact that you don't realise that it's substantive is irrelevant;
2) you can talk about whatever you like, and we ask only that you find a newsgroup where that subject is topical;
3) whilst we do occasionally have discussions emanating from off-topic questions, that isn't really "what we do" - what we do is C, and some of the folks here are extremely good at it.
In addition to the above, we sometimes talk about popular extensions
to
the c langauge that are resident in nearly all implementations of the
standard c library and that in itself is still on topic IMHO so long
as
it's clear that it's not an official part of the standard. This
distinction is very important because newcomers to the group may think

that the extension we are discussing is part of the actual c standard
and then we grow a new breed of misguided programmers. To further
prove
this point, I used to work with a few guys who thought that MFC
(Microsoft Foundation Classes) were in fact part of the standard c
library as outlined by the C89 standard and they would argue with me
over it for hours at a time if I let them.

You appear to delight in parading your ignorance of these facts, so that all the world may know that you cannot grasp a simple classification concept such as topicality.
I've noticed this more and more over the past few weeks. Kenny seems
to
like disrupting posts in order to delight himself (or so it would seem

since none of the regulars seem to pay him any mind). He always whines

and complains that we're strictly on topic here and that is not always

the case. We don't always adhere to the rules when replying to a
message
(my reply being case and point), however nobody minds. Even when a
post
does not adhere to the rules here, we prefix the message with the
characters [OT] which allows others to filter out the junk from the
juice.

You also seem to think that the opinions you express on comp.lang.c are worth as much as anyone else's. Well, they will be, when (and only when) you demonstrate that your knowledge of C is sufficiently encyclopaedic that it becomes a good use of people's time to put up with your drivel for the sake of your expertise. Until then, you will always remain mere background noise.

Well put and I completely agree. Perhaps Kenny will one day grow up
and
learn that this newsgroup is not a battleground for showing off your
leet typing skills, rather it is an invaluable tool to those of us who

actually know c and need a little help now and again. Of course I
personaly feel that by the time this happens earth will no longer be
populated with c programmers as we will all have established life on
another planet that is not infested with trolls such as Kenny. Again,
that's just my personal view on things.

That's just my two cents.

Joe

Dec 3 '05 #26
In article <rjlkf.592543$x 96.146168@attbi _s72>,
Joe Estock <je*****@NOSPAM nutextonline.co m> wrote:
....
Well put and I completely agree. Perhaps Kenny will one day grow up and
learn that this newsgroup is not a battleground for showing off your
leet typing skills, rather it is an invaluable tool to those of us who
actually know c and need a little help now and again. Of course I
personaly feel that by the time this happens earth will no longer be
populated with c programmers as we will all have established life on
another planet that is not infested with trolls such as Kenny. Again,
that's just my personal view on things.
My intent is A) never to grow up and B) never to post the same message
twice.
That's just my two cents.


4 cents now.

Dec 3 '05 #27

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2502
by: Anand Pillai | last post by:
Hi Folks (posting after a loooong time...) I have been contracted by an Indian publisher to author an introductory text book on Python. As a part of the introductory chapter, I thought it would be a good idea to present a number, a round-about figure on the approximate *actual* usage of Python out there in number of developers and/or installations.
3
4155
by: Ian Taite | last post by:
Hello, I'm exploring why one of my C# .NET apps has "high" memory usage, and whether I can reduce the memory usage. I have an app that wakes up and processes text files into a database periodically. What happens, is that the app reads the contents of a text file line by line into an ArrayList. Each element of the ArrayList is a string representing a record from the file. The ArrayList is then processed, and the arraylist goes out of...
1
2428
by: Jason | last post by:
Greetings, Is there a reliable and portable way of getting malloc statistics within a running C program? I have tried to use the mallinfo() command, but it isn't portable (reports different things on linux and HP), and Purify reports memory access violations with it. At any given point in a program, I would like to grab total used memory for the process. Does anyone have a good way of doing this? Thanks Jason
4
3563
by: serge | last post by:
I am running a query in SQL 2000 SP4, Windows 2000 Server that is not being shared with any other users or any sql connections users. The db involves a lot of tables, JOINs, LEFT JOINs, UNIONS etc... Ok it's not a pretty code and my job is to make it better. But for now one thing I would like to understand with your help is why the same SP on the same server and everything the same without me changing anything at all in terms of SQL...
17
5108
by: romixnews | last post by:
Hi, I'm facing the problem of analyzing a memory allocation dynamic and object creation dynamics of a very big C++ application with a goal of optimizing its performance and eventually also identifying memory leaks. The application in question is the Mozilla Web Browser. I also have had similar tasks before in the compiler construction area. And it is easy to come up with many more examples, where such kind of statistics can be very...
5
1747
by: Allan Ebdrup | last post by:
Hi We have a large class library of different classes, now we are going to implement a lot of usage statistics that we need, stuff like how many times a user has logged in, how many times a message has been read, how many times a ad has been shown and so on. Now I'm wondering what would be a good OO organization of this data, should the statistics be part of the objects they are for, or should statistics be seperate. Perhaps each object...
2
2681
by: Quasar | last post by:
Hi everybody! I''ve created a script that enable the statistics for a specific DB: #!/bin/sh if ; then echo Enabling monitoring switches for ${1} db2 connect to ${1} db2 update monitor switches using TABLE on UOW on TIMESTAMP on STATEMENT on BUFFERPOOL on LOCK on SORT on
1
2051
by: Jean-Paul Calderone | last post by:
On Tue, 22 Apr 2008 14:54:37 -0700 (PDT), yzghan@gmail.com wrote: The test doesn't demonstrate any leaks. It does demonstrate that memory usage can remain at or near peak memory usage even after the objects for which that memory was allocated are no longer live in the process. This is only a leak if peak memory goes up again each time you create any new objects. Try repeated allocations of a large dictionary and observe how memory...
10
6544
by: w.l.fischer | last post by:
Is it possible to have statistics on temporary tables? I frequently put 10000 or more rows in a temporary table and would like to know it the queries become faster with statistics on those tables.
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10369
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.