-
continous memory
hi,
i've read that calling malloc or new dosn't mean you'll get continous memory allocated to your program. this is a bit of a problem in a program i'm writing, where being able to use pointer additio would simplify things. can anyone tell me how continuous memory can be acquired in a win32 environment ? its no big deal if it only works on the WIN32_NT platform
thanks in advance.
-
You don't have to worry about it - the OS will take care of it in a way that is invisible to your program. That's the beauty of protected-mode operating systems. :)
-
> i've read that calling malloc or new dosn't mean you'll get continous memory allocated to your program
Get a better source of information then - it's wrong. The memory in any single block you get with malloc/new will be contiguous.
However, given
p = malloc(10);
q = malloc(10);
You can't make any statement about the relationship between p and q
-
>> i've read that calling malloc or new dosn't mean you'll get continous memory allocated to your program
>Get a better source of information then - it's wrong. The memory in any single block you get with malloc/new will be contiguous.
guess thats the trouble with the internet :rolleyes: . thanks to both of you for your help :)
-
It's definitly continous in virtual memory, and that means all practical purposes, but the implementation can do whatever it wants to with physical memory?
-
If you need a continuous block of memory, allocate everything you need at once, with one new statement.
If you allocate it using several new statements, it's not guaranteed to be continuous.
(Yes Salem, I know I just repeated what you said)
-
Or you can overload the new operator to create a pool system.
okinrus, well, if you want more informations about how the memory is used and the relationship between physical and virtual memory, you should go to the Intel developers site and get the 3rd manual of the IA-32. Because, there are paging, segmentation and other stuffs like that which make it difficult to give an exact answer here.