By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,421 Members | 1,127 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,421 IT Pros & Developers. It's quick & easy.

Memory usage/Fragmentation

P: n/a
Hello,

I m working on Windows and Mac in C++. My application uses a lot of
memory since it s dealing with a lot of images.
So I load images in a cache when needed and if I haven t enough memory
to load next image I remove first ones from the cache.
But I have a lot of problems with memory. A lot of time when I just ask
for memory, a big chunk of memory though, like for example 200 Mo the
new/malloc returns NULL but as far as I can see in the ressource monitor
I still have a lot of memory available (far more than 200 Mo)!
After looking on the web this seems to be a problem due to memory
fragmentation, but how to change this ? what can I do ?

Other things is that it seems that my application cannot use more than
2Go of RAM even if I have a computer with more than that (3, 4 or even 5
Go). Any info on this ?

And last, should I consider using map file to reduce memory usage
(allocation/deallocation) ? any benefit from this ?

Thanks,

Dlp
Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Are you dealing with 200 MB images?

If the images are smaller but you are allocating memory for a set of
images,
I would recommend allocating memory for each image separately.

Deepa
--
EventStudio 2.5 - http://www.EventHelix.com/EventStudio
Enter model in plain text;generate sequence diagram in PDF/Word

Jul 23 '05 #2

P: n/a
Are you dealing with 200 MB images?


yes, and even more for example 20000x10000 pixels images ...

Dlp
Jul 23 '05 #3

P: n/a
DLPnet wrote:
Are you dealing with 200 MB images?


yes, and even more for example 20000x10000 pixels images ...


There are libraries that are specifically designed to deal with such big
images. They don't load the whole image at once, but just the parts of it
that are needed. Depending on the image format, this can be very efficient.

Jul 23 '05 #4

P: n/a
DLPnet wrote:

Hello,

I m working on Windows and Mac in C++. My application uses a lot of
memory since it s dealing with a lot of images.
So I load images in a cache when needed and if I haven t enough memory
to load next image I remove first ones from the cache.
But I have a lot of problems with memory. A lot of time when I just ask
for memory, a big chunk of memory though, like for example 200 Mo the
new/malloc returns NULL but as far as I can see in the ressource monitor
I still have a lot of memory available (far more than 200 Mo)!
After looking on the web this seems to be a problem due to memory
fragmentation,
Could be
but how to change this ? what can I do ?
Not allocating that much memory in one big chunk.

You could eg. set up a structure where each line in the image has
its own memory allocation. So instead of allocating one memory block
for one 20000 * 10000 pixel image. You have 20000 allocations for
10000 pixel each plus 1 allocation for an array of 20000 pointers.

Other things is that it seems that my application cannot use more than
2Go of RAM even if I have a computer with more than that (3, 4 or even 5
Go). Any info on this ?
That's compiler dependent or operating system dependent.

And last, should I consider using map file to reduce memory usage
(allocation/deallocation) ? any benefit from this ?


Don't know. Try it.
When you get into such large memory usage you need to get creative on what
to do to reduce problems. Problems for the programmer *and* problems for
the operating system *and* problems for the runtime system.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #5

P: n/a
DLPnet wrote:
Hello,

I m working on Windows and Mac in C++. My application uses a lot of
memory since it s dealing with a lot of images.
So I load images in a cache when needed and if I haven t enough memory
to load next image I remove first ones from the cache.
But I have a lot of problems with memory. A lot of time when I just ask
for memory, a big chunk of memory though, like for example 200 Mo the
new/malloc returns NULL but as far as I can see in the ressource monitor
I still have a lot of memory available (far more than 200 Mo)!
After looking on the web this seems to be a problem due to memory
fragmentation, but how to change this ? what can I do ?

Other things is that it seems that my application cannot use more than
2Go of RAM even if I have a computer with more than that (3, 4 or even 5
Go). Any info on this ?

And last, should I consider using map file to reduce memory usage
(allocation/deallocation) ? any benefit from this ?

In Windows there is a limit of memory per application. I do not remember
how much this is for Windows x86, but it is about 512 MB (perhaps so
much exactly).
Some similar restriction may exist in Mac and any other OS.


--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.