473,466 Members | 1,511 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

memory approximation

Hi,

Any suggestions for estimating the amount of memory a program will
use in advance, before it is run. Rules of thumb etc.?

Is it then possible to warn a user that a program is likely to crash
at start up? Swap space issues etc.......

Douglas
Nov 14 '05 #1
4 2641
Douglas a couché sur son écran :
Any suggestions for estimating the amount of memory a program will
use in advance, before it is run. Rules of thumb etc.?

Is it then possible to warn a user that a program is likely to crash
at start up? Swap space issues etc.......


The mapping file generated by your linker can give an idea about the
code size and the static memory. Of course, there is no way to predict
your use of the allocated nor automatic memory.

--
Emmanuel
The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html

"C is a sharp tool"

Nov 14 '05 #2
On Fri, 23 Jul 2004, Douglas wrote:
Hi,

Any suggestions for estimating the amount of memory a program will
use in advance, before it is run. Rules of thumb etc.?

Is it then possible to warn a user that a program is likely to crash
at start up? Swap space issues etc.......


There is static and dynamic memory usage. If you have your linker generate
a map file you can know how much static memory will be used. The dynamic
memory usage is a little harder. For that you probably want to ask in a
newsgroup that deals with your compiler and environment. There are often
tools for monitoring stack usage and heap size. Some operating systems
will have performance tools that let you track these issues.

One thing you will need to do is generate worst case scenarios. If the
program has external inputs that affect the running, memory usage will
change with each run. You need to figure out worst case, run it and
monitor the memory usage.

You might also want to ask this question in comp.programming or
comp.software-eng.

--
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vi************@whitehouse.gov
Nov 14 '05 #3

"Douglas" <mm***@yahoo.co.uk> wrote in

Any suggestions for estimating the amount of memory a program will
use in advance, before it is run. Rules of thumb etc.?

Is it then possible to warn a user that a program is likely to crash
at start up? Swap space issues etc.......

Unless you are coding in a very unusual way, what matters is the calls to
malloc().
Usually you won't know exactly how much memory you need at compile time, but
sometimes you can guess. If you know that most images you work on are
designed for TV, then that will tell you how many pixels are likely to be in
each image, and thus how much memory you need to store them. If you know
that your client has around 200,000 customers, then that will tell you how
much memory you need to hold an account record for each one.

Most programs have a single data structure which accounts for virtually all
the memory used, and you can ignore little bits. Video games are an
exception, when mesh data, images and audio can all gobble large amounts of
memory, so you need to take note of all three.

ANSI C doesn't provide a "coreleft" but it is a common extension. What you
need to do is call this function, and if there isn't enough memory put up a
warning saying "we recommend that at least xx MB be available".
Nov 14 '05 #4
"Malcolm" <ma*****@55bank.freeserve.co.uk> writes:
"Douglas" <mm***@yahoo.co.uk> wrote in

Any suggestions for estimating the amount of memory a program will
use in advance, before it is run. Rules of thumb etc.?

Is it then possible to warn a user that a program is likely to crash
at start up? Swap space issues etc.......

[...]
ANSI C doesn't provide a "coreleft" but it is a common extension. What you
need to do is call this function, and if there isn't enough memory put up a
warning saying "we recommend that at least xx MB be available".


I've never met a function named coreleft() under Unix, and I
don't think that Win32 provides one either. In fact, as far as I
know only MS-DOS compilers have coreleft(). Because the OP is
talking about swap, he's probably not working under MS-DOS.
--
"Welcome to the wonderful world of undefined behavior, where the demons
are nasal and the DeathStation users are nervous." --Daniel Fox
Nov 14 '05 #5

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

Similar topics

12
by: Anon | last post by:
Hello all, I'm hoping for some guidance here... I am a c/c++ "expert", but a complete python virgin. I'm trying to create a program that loads in the entire FreeDB database (excluding the...
5
by: Jason Callas | last post by:
I was doing starting some experimenting with the GC and ran into the following odd result. I created an object and my used memory went up by almost 11k but when I cleared it and forced a collection...
22
by: xixi | last post by:
hi, we are using db2 udb v8.1 for windows, i have changed the buffer pool size to accommadate better performance, say size 200000, if i have multiple connection to the same database from...
2
by: Saber | last post by:
Public Class User Private _id, _P, _L, _R As Integer Private _balance As Int64 Private _name, _family, _tel1, _tel2, _mobile, _city, _accountNumber As String Private _password, _email,...
7
by: Roy Smith | last post by:
I've got a large text processing task to attack (it's actually a genomics task; matching DNA probes against bacterial genomes). I've got roughly 200,000 probes, each of which is a 25 character...
10
by: mdh | last post by:
Quick question about pointers. Wrote this "trying to understand this better" code: int *ptr, x = 565; ptr= &x; printf("\n\n\nThe value of x is %d\n", x);
12
by: james121285 | last post by:
This is my first ever program. I have struggled big time and its token so long my university lab is closed, can someone please check this over and maybe even correct some parts. I would be so happy...
3
by: emer.kurbegovic | last post by:
how can i get heap memory of a windows process with C#? For example, I would like to see the value of the heap memory allocated for my "java.exe" process. thanks in advance.
2
by: dmitrey | last post by:
hi all, I have a python list of unknown length, that sequentially grows up via adding single elements. Each element has same size in memory (numpy.array of shape 1 x N, N is known from the very...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.