> I have got the following problem:
> I need a way to get the memory size used by my program.
> It should look like the following:
Thats a fairly vague question, as malloc does not necessecarily increase the
amount of memory allocated to a process. Is it actual allocated memory you are
after, or allocated address space?
> int mem = getUsedMemory();
> char * buffer = (char*)malloc(1024);
> mem = getUsedMemory(); // now mem should be 1024 bytes bigger
> Is there already such e function or, if not, how can i implement
There is not such a function, but if you are interested, in /proc/<pid> where
<pid> is the proccess id number of your program, there is a file called status.
In that file there are several lines prefixed with the characters "Vm" These
values represent the amount of allocated address space a process has, if that
helps you at all. You may be able to implement your function using these
values. Mind, however, that they do not represent the amount of memory your
program is actually using.
> Any pointers aprecciated,