471,119 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,119 software developers and data experts.

Memory usage/Fragmentation

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
5 1910
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
Are you dealing with 200 MB images?


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

Dlp
Jul 23 '05 #3
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
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
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.

Similar topics

8 posts views Thread by Tron Thomas | last post: by
18 posts views Thread by Tron Thomas | last post: by
74 posts views Thread by ballpointpenthief | last post: by
9 posts views Thread by jeungster | last post: by
5 posts views Thread by Andreas Schmitt | last post: by
6 posts views Thread by CMOS | last post: by
10 posts views Thread by Daniel Peterson | last post: by
8 posts views Thread by jacek.dziedzic | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.