Vardhan, Sundara (GE Infra, Energy) wrote:
Desperate: Do not know if this is the right forum for this
question. Using gcc 4.1.1 on Red Hat Linux, I keep getting negative
pointer value when I try to allocate more than 128000 bytest using
malloc(). Works fine if the value is less than 128000. Any ideas why
this happens. I would very much appreciate your help and input.
It sounds like a: a misconception on your part (what is a "negative
pointer" and why do you think this is a problem?), and b: a boundary
across which malloc() uses the heap vs. doing a mmap().
Probably you are confusing "negative" for the address space 0x80000000 -
0xFFFFFFFF, the heap lives below this, and 128000 (probably the actual
value is closer to 131072 == 128 KiB, perhaps a bit less for
heap-related structures hanging off one of the ends of the block) is the
threshold for mmap() vs. heap allocation. So smaller requests come from
the heap, and larger ones are mmap()d (incidentally from the 0x80000000
- 0xFFFFFFFF range on your OS).
...and a glibc (or newlib, or whoever provides your libc) forum/list is
probably more appropriate :-).
--
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
--
C++ is for people who want to be able to not just shoot themselves in
the foot, but do it with a rocket launcher. -- Igor Peshansky