ietf
[Top] [All Lists]

RE: Memory Problem

2003-03-14 08:34:14
Hi Vladis & Chandani,

My 2 cents!...
Let me define the problem first.
Chandani, You are using a system which has unsigned short set to 16
bits.
So, the maximum value of unsigned short can be just 64k. malloc takes
unsigned short as argument and obviously maximum you can pass in , is
64k.So, the maximum size which can alloc'ed is 64k.

There can be few solutions:
1. There is a limits.h file which defines the max size of various types.
Please check the "long" size max value. If it corresponds to 32 bits,
then you can also configure short as the same max size as long. This
will allow you to malloc more than 64 k in a chunk.
2.If your system still is 16bits, then the other solution is to write
your own small memory manager on top of malloc
My_malloc( number of multiples, 64k)
This call will allocate 64k chunks using malloc and maintain pointers to
each block but, will make it appear to the pgm that all blocks are
contiguous. More details, please check for info about writing a memory
management layer.
3. Look at pgm requmt . Do you really need one chunk. Or, you can do
with multiple chunks. May be you can write a wrapper which can accepts
multiple data blocks of bmp.

Vladis, to an extent you are right that chandani is using an older
system, but, that's not the correct explanation of the problem.


Regards,
shivendra

-----Original Message-----
From: Valdis(_dot_)Kletnieks(_at_)vt(_dot_)edu 
[mailto:Valdis(_dot_)Kletnieks(_at_)vt(_dot_)edu] 
Sent: Friday, March 14, 2003 7:30 PM
To: Chandani, Chirag
Cc: ietf(_at_)ietf(_dot_)org
Subject: Re: Memory Problem 


On Fri, 14 Mar 2003 11:33:39 GMT, "Chandani, Chirag"
<c10c(_at_)rediffmail(_dot_)com>  said:
I want to allocate about 600K of memory in a C Program where i
load a .Bmp image but Malloc() doesnt allow allocation of more 
than 64 K
Is there some way out

1) Ask on an intro-to-C mailing list.

2) Learn to give relevant information - are you using some Microsoft
software, or are you compiling on a BSD 2.11 system on a PDP-11?  What
error does malloc() return?  What option(s) did you compile with? etc
etc?

3) There's a better-than-even chance that you're compiling on some
broken system where you have to jump through hoops to get rational
memory management. If so, your only long-term real hope is to use
software that actually works.
-- 
                                Valdis Kletnieks
                                Computer Systems Senior Engineer
                                Virginia Tech




<Prev in Thread] Current Thread [Next in Thread>