472,982 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,982 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 1973
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Tron Thomas | last post by:
As part of applying for a programming position at a company, I recently I had submitted some code samples to one of the developers for review. This is the feedback I received: One of his...
18
by: Tron Thomas | last post by:
Given the following information about memory management in C++: ----- The c-runtime dynamic memory manager (and most other commercial memory managers) has issues with fragmentation similar to a...
35
by: Alex Martelli | last post by:
Having fixed a memory leak (not the leak of a Python reference, some other stuff I wasn't properly freeing in certain cases) in a C-coded extension I maintain, I need a way to test that the leak is...
74
by: ballpointpenthief | last post by:
If I have malloc()'ed a pointer and want to read from it as if it were an array, I need to know that I won't be reading past the last index. If this is a pointer to a pointer, a common technique...
9
by: jeungster | last post by:
Hello, I'm trying to track down a memory issue with a C++ application that I'm working on: In a nutshell, the resident memory usage of my program continues to grow as the program runs. It...
5
by: Andreas Schmitt | last post by:
Hi, I recently worked on an open source project and tried to make on of the arrays they are using dynamically allocated to get rid of the max size. I used the realloc instead of the usual C++...
6
by: CMOS | last post by:
consider the below code. it just creates a map and inserts 51000000 elements. when i check the memory usage , it shows an increase of memory after the loop. the increase is around 2mb. i used "ps...
10
by: Daniel Peterson | last post by:
I'm responsible for a pair of IIS 6 webservers that run our production ASP.Net application. We push code on a monthly basis, and about two weeks after our October code push, we started to run into...
8
by: jacek.dziedzic | last post by:
Hi! I need to be able to track memory usage in a medium-sized application I'm developing. The only significant (memory-wise) non- local objects are of two types -- std::vector<and of a custom...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.