Thank you very much for your replies. I undestand all your patience and hope
you will not get angry... Here is my new scenario to clearify last questions
in my mind.
You have 2GB physical memory, with /3GB option set in the boot.ini.
memory. You try to run the following code:
...
in the physical memory. If I am dependent on the free block size of the
In article <842B1F58-BCB6-4AEF-9FF1-B77B0C0606B2@microsoft.com>,
=?Utf-8?B?bXVzdGFmYQ==?= <mustafa@newsgroup.nospam> wrote:
1) If some part of my 2GB physical memory consumed by other programs with
small memory blocks, and there is no 1GB big free block in the physical
memory, and when I need 1 GB for my array, why WinXP dont make
defragmentation?
Because memory is *owned* by programs in C/C++. When you have a
pointer to memory, you can't just shuffle it around behind the
program's back. Ownership means that things must *stay* where you put
them.
2) Am I right that one application can use maximum 3GB memory in WinXP, if
you have 2GB physical memory and your boot.ini is set with /3GB parameter...
Then What about if I will increase my physical memory to 4GB ? Again single
application is limited to 3GB?
Yes. Because WinXP is a 32-bit OS. 32 bits per process can access
4GB of space -- do the math. The OS needs to be available to all
applications, which is why is reserves 1 or 2 GB of the per-process
4GB limit so that your program can talk to the OS.
3) What I really wonder is, when I need 2GB memory block, in a computer with
2GB physical memory, why WinXP gives out of memory error instead of using
the virtual memory?
Virtual memory won't help. You're insisting on a contiguous 2GB
chunk of memory. That *must* be available within the first 3GB of your
processes memory space to succeed. If you don't have that amount of
memory available, then it'll fail.
Frankly, your options are as follows:
1) Understand what your 3rd party library is doing and change it so
that it doesn't create extra copies of the buffer you pass in.
2) Switch to a 64-bit OS, compiler, etc.
#2 is more expensive, but may well be the best bet for you. You've
shown a remarkable insistence on doing things "your way," and been
adamant that the OS should "defragment" memory for you. That's not the
way things work. There's a lot of humility needed in programming to
understand how and why things work the way they do. So far, you've not
demonstrated much of that. It'll be easier for you to change your
third party library than it'll be to get defragmented memory.
Nathan Mates
--
<*> Nathan Mates - personal webpage http://www.visi.com/~nathan/
# Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
# NOT speaking for Pandemic Studios. "Care not what the neighbors
# think. What are the facts, and to how many decimal places?" -R.A. Heinlein