Q:malloc
From: Michael Schuster (schusterSoccer_at_enertex.de)
Date: 05/27/04
- Next message: Josef Moellers: "Re: why I told dd command to write but it reads in first?"
- Previous message: Kasper Dupont: "Re: IKBOCS - Object Oriented Operating System"
- Next in thread: Jens.Toerring_at_physik.fu-berlin.de: "Re: Q:malloc"
- Reply: Jens.Toerring_at_physik.fu-berlin.de: "Re: Q:malloc"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 27 May 2004 08:49:13 +0200
Hi,
I'm having a question referring malloc, refering to the docs of libc,
I found:
"The address of a block returned by `malloc' or `realloc' in the GNU
system is always a multiple of eight (or sixteen on 64-bit systems)"
Does this mean, if I compile:
int *m1;
m1=malloc(sizeof(int))
that the system occupates at least 8 (16 on a 64 Bit system) Words of
memory ?
So if my next instruction would be:
int *m2;
m2=malloc(sizeof(int))
my system would occupy already at least 16 (32) Bytes?
Also does the pointer allocation itself (int *m1 or int *m2) occupy
sizeof(int*) Bytes or at least 8 (or 16) Words?
I encountered the problem with my programm using a lot of void* - pointers
with only 1 element allocated with malloc. Due to my expirience (gcc (GCC)
3.3.3 (SuSE 9.1 Linux) ) with /proc/PID/status or top every malloc of an
void* needs at least 16 Bytes (or 4 32-Bit words). So in my programm the
system allocates the same space for
int *m1;
m1=malloc(sizeof(int))
and
int *m1;
m1=malloc(sizeof(int)*3)
Thanks for any comment!
Michael
-- Remove the sport from my address to obtain email www.enertex.de - Innovative Systemlösungen der Energie- und Elektrotechnik
- Next message: Josef Moellers: "Re: why I told dd command to write but it reads in first?"
- Previous message: Kasper Dupont: "Re: IKBOCS - Object Oriented Operating System"
- Next in thread: Jens.Toerring_at_physik.fu-berlin.de: "Re: Q:malloc"
- Reply: Jens.Toerring_at_physik.fu-berlin.de: "Re: Q:malloc"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|