Windows 7 - D3DXCreateTexture returns E_OUTOFMEMORY

Asked By joh on 01-Mar-07 06:07 AM
D3DXCreateTexture   returns  E_OUTOFMEMORY .

I run my program.
it consumes 700Mb system memory,when loading.
I calculated this using windows task manager [ctrl+alt+del].

total system mem is 1 Gyga Bytes.

so after loading my program,
almost 1 GBytes used, and very few available memory.

my program runs for a while.
and D3DXCreateTexture  returns  E_OUTOFMEMORY.

D3DXCreateTexture  fails.
so I retried using

while( )
// until D3DXCreateTexture  returns ok ..
call .. D3DXCreateTexture

but .. it never returns ok.

so I can't create texture anymore.

of course, I just put another 1G memory card
the problem will be solved (70% ? possibility)

I want to know

why D3DXCreateTexture  fails often ?
even when more memory can be allocated using virtual memory .
that is .. page file swaping ..

Geoffrey Summerhayes replied on 01-Mar-07 11:52 AM
It won't. Once you fill a glass with water it
doesn't matter how much more you pour, the only
way to get more water in is to take some out.

Unlikely. A 32-bit program gets 2GB user +
2GB system as its virtual environment. The
OS keeps track of how that maps to physical
memory and disk.

Ten to one you have a memory leak, the program
has allocated, used, and finished with a chunk
of memory, but failed to release it. Even if
it's just 4 bytes in one function call, the more
the function is called, the faster the program will
use up all the available memory.

joh replied on 01-Mar-07 07:17 PM
thank you very much !

I create textures [ about 900 textures but very small ]

I create textures , most of them [880/900] are 8*8, 16*16 pixel size.
very few [ 20/900 ] are 32*32, 64*64, 128*128, 256*256

but about 900 times.

and I do not release it.
I put texture pointers to queue using std::deque .

and reusing it.

that is .. check deque and if i found texture pointer available,
I use it. [ not newly creating texture]

but   this can cause outofmemory errors ?
legalize+jeeve replied on 01-Mar-07 07:34 PM
[Please do not mail me a copy of your followup]

=?Utf-8?B?am9obg==?= <john@> spake the secret code

You would be much better off creating a large texture and parceling it
out to the smaller images, particularly if these aren't mipmapped.

Legalize Adulthood! <>
joh replied on 01-Mar-07 08:33 PM
thanks. I will do it someday !

but now, I have to solve OUTOFMEMORY error in a week or so.

making small textures a  lot  can cause memory leak ?
legalize+jeeve replied on 01-Mar-07 09:25 PM
[Please do not mail me a copy of your followup]

=?Utf-8?B?am9obg==?= <john@> spake the secret code

Well, when you do it "someday" you will probably have solved your

Most memory allocation algorithms do the worst when you allocate lots
of little objects.  You pay the most overhead that way.

Legalize Adulthood! <>
joh replied on 02-Mar-07 12:55 AM

is there any method that I can manage memory directly ?

and another question,

even in 900 times texture create calls,
it consumes only a few Mega Bytes , at most less than 10 Mbytes.'
because textures are very small [8*8 pixels].

even in small memory fragments,
maybe , I guess a lot of available memory still exists.

but D3DXCreateTexture returns OutOfMemory.

why this occurs ?

then, heap size is very small in my program ?

or  I have already used many heap memory when loading other resources
like vertex buffer, other textures for objects and characters.
and general buffers like string arrays or others.

I use 1G system memory,
and my program use 700M when loading on initial loading
when I saw in windows task manager .

and I have created most textures and VB, IB  with MANAGED POOL option.