Advertisement

Can't allocate enough memory!

Started by July 30, 2000 04:37 PM
5 comments, last by Cajun Coder 24 years, 4 months ago
I am writting a simple program that loads and displays a model from a file. Things are going great, but I can''t get enough memory to store large textures [large being > 256 * 256 @ 24 bit]. I have 64 Megs of ram with 16 on the video card, however, either model->texture = new char [nTexWidth * nTexHeight * 3] == NULL or it is not equal to null and crashes once I access some arbitrary element in the middle of nowhere... IE model->texture [205] or model->texture [168] My program works great for anything below and from 256^2, but it''s just not behaving past that. Is their any way I can get the ''new'' operator to get memory from EMS? I have even gone so far as to try the C functions malloc, calloc but all to no avail... I know the memory is free, but I just cant ''use'' it.. Any ideas? Regardless thanks for your time. -Chris Smith <8D)o<
If you''re programming under DOS, you should consider using some EMS Manager. If you''re under Windows, this shouldn''t be your problem''s source. Try to allocate the memory with malloc(nTexWidth * nTexHeight * 3) and see what this does. btw, you have to release the texture pointer with free( model->texture ) instead of delete[] model->texture.

Post again if this doesn''t work either.

HTH

pi~
Jan PieczkowskiBrainwave Studios
Advertisement
get more memory.

JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
do you do

if( model->texture = new char [nTexWidth * nTexHeight * 3] == NULL )

??
Ries
256^2-> 65536 ...ems ... OH MY GOD HE''S STILL USING DOS!

Sorry, I think there are ways to get more that the 64k blocks in dos, but I really don''t know how...

maybe you can create wrapper class with an array of pointers to an array of chars, allocate 64k blocks into each of them, and implement the [] operator to emulate linear memory...

You know, I think this was the main reason why I switched to windows programming.

You know, I never wanted to be a programmer...

Alexandre Moura
I know your problem, I''ve had a similar one in the DOS days. The answer is pretty simple, use a DOS extender. I used to use Watcom as it came with a free, royalty free extender (DOS4GW). TC3, I think doesn''t have one (it only compiles 16bit binaries). And if you use DJGPP, it should be able to go into 32bit (which is what you want).

Look at all your compile options and find something that''ll compile a 32bit binary, or anything that''ll make your program compile using the "flat" memory model. That should get rid of the 64kb boundry.

btw, which compiler are you using?

~Queasy.
Jonathan Makqueasy gamesgate 88[email=jon.mak@utoronto.ca]email[/email]
Advertisement
Yes...use DJGPP...
In case anybody didn''t know, DJGPP is a free, open source ,32 bit PMODE c/c++ compiler for DOS (of course, it runs fine in Windoze too). http://www.delorie.com/djgpp


Martee
Magnum Games
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers

This topic is closed to new replies.

Advertisement