473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

memory usage

Hi there,

is there a function in standard C to find out how much memory is used?
Or better, a function to find out how much memory is used by the
application itself.

Thanks
Nov 13 '05 #1
6 10520
In article <0t********************************@4ax.com>, Tim Quon wrote:
is there a function in standard C to find out how much memory is used?


No, sorry. You could yourself keep track of the number of bytes
allocated with malloc() et al., but AFAIK this does not need
to be exactly the amount of memory that your application makes
use of on the computer. For that you will probably need an
operating system utility such as 'ps' or 'top' on Unix systems.

--
Andreas Kähäri
Nov 13 '05 #2
On Mon, 15 Sep 2003 15:57:13 +0000 (UTC), Andreas Kahari
<ak*******@freeshell.org> wrote:
In article <0t********************************@4ax.com>, Tim Quon wrote:
is there a function in standard C to find out how much memory is used?


No, sorry. You could yourself keep track of the number of bytes
allocated with malloc() et al., but AFAIK this does not need
to be exactly the amount of memory that your application makes
use of on the computer. For that you will probably need an
operating system utility such as 'ps' or 'top' on Unix systems.


Do you know how to use the mstats() function.
Nov 13 '05 #3
Tim Quon <ti***@freesurf.ch> writes:
Do you know how to use the mstats() function.


There is no standard mstats() function. If your system has one,
please refer to a system-specific manual, newsgroup, etc., to
find out more information about it.
--
"I'm not here to convince idiots not to be stupid.
They won't listen anyway."
--Dann Corbit
Nov 13 '05 #4
Tim Quon wrote:
Is there a function in standard C to find out how much memory is used?
No.
Or better, a function
to find out how much memory is used by the application itself.


You would need to make an implementation dependent
operating system call. For UNIX, take a look at
SYNOPSIS
#include <sys/resource.h>

int getrusage(int who, struct rusage *usage);

CONFORMING TO
SVr4, BSD 4.3

Nov 13 '05 #5
In 'comp.lang.c', Tim Quon <ti***@freesurf.ch> wrote:
is there a function in standard C to find out how much memory is used?
Or better, a function to find out how much memory is used by the
application itself.


No, and in real life, it will probably be a nonsense, because most of the
application are constantly allocating/freeing memory. (For static memory,
just read the mapping made by your linker)

That said, on embedded systems, I use a wrapper to malloc()/free() that
counts the alloc/free operations (useful to detect a memory leak), and
records the size of the biggest allocated chunk (useless at the moment).

--
-ed- em**********@noos.fr [remove YOURBRA before answering me]
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
<blank line>
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 13 '05 #6
In 'comp.lang.c', Tim Quon <ti***@freesurf.ch> wrote:
Do you know how to use the mstats() function.


Non standard, hence off-topic here. Please ask on a newsgroup dedicated to
your system or implementation.

--
-ed- em**********@noos.fr [remove YOURBRA before answering me]
The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
<blank line>
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/
Nov 13 '05 #7

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

Similar topics

8
by: rbt | last post by:
Would a Python process consume more memory on a PC with lots of memory? For example, say I have the same Python script running on two WinXP computers that both have Python 2.4.0. One computer has...
5
by: Justice | last post by:
Currently I'm doing some experimenting with the XMLHTTP object in Javascript. Now, the XMLHttp object is asynchronous (at least in this case), and the following code causes a significant memory...
2
by: tomvr | last post by:
Hello I have noticed some 'weird' memory usage in a vb.net windows app The situation is as follows I have an app (heavy on images) with 2 forms (actually there are more forms and on starting...
6
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that,...
2
by: Jarvis | last post by:
I've made a testing program to test the memory usage of some Data Forms. I create a MDI parent form with one single MDI child form, which is a Data Form generated by .NET Data Form Wizard. To...
3
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...
20
by: Philip Carnstam | last post by:
How come .Net applications use so much memory? Every application I compile uses at least 10 MB of memory, even the ones consisting of only a form and nothing else. If I minimize them though the...
13
by: Ilias Lazaridis | last post by:
How to detect memory leaks of python programms, which run in an environment like this: * Suse Linux 9.3 * Apache * mod_python The problem occoured after some updates on the infrastructure....
1
by: yzghan | last post by:
Hi all, I feel that my python script is leaking memory. And this is a test I have: log.write(" " + "test() ... memory usage: " + " ".join(repr(i/(1024*1024)) for i in getMemInfo()) + "\n") m...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.