A Windows XP help forum. PCbanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » PCbanter forum » Microsoft Windows XP » Performance and Maintainance of XP
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

No memory although more than 1GB free



 
 
Thread Tools Display Modes
  #61  
Old February 6th 04, 07:55 AM
Stephen Howe
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

Thanks a lot, Igor, I got it!

Which container types of the STL are you using Klaus?
And which version of VC++ are you using?

Stephen Howe


Ads
  #62  
Old February 6th 04, 07:56 AM
Klaus Bonadt
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

Xref: kermit microsoft.public.vc.language:144422 microsoft.public.vc.stl:18899 microsoft.public.windowsxp.perform_maintain:155681

Which container types of the STL are you using Klaus?
And which version of VC++ are you using?


In first place I use map and vector with VC++ version 6 with some header
replacements.

Regards,
Klaus


  #63  
Old February 6th 04, 07:59 AM
Nick Savoiu
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

"Klaus Bonadt" wrote in message
...
It seems that you could have that case. You could try to walk the

virtual
address space and see what's going on. Check out VirtualQueryEx().


DWORD VirtualQuery(
LPCVOID lpAddress, // address of region
PMEMORY_BASIC_INFORMATION lpBuffer, // information buffer
SIZE_T dwLength // size of buffer
);

Two questions:
1.
How to set lpAddress initially?


You can start it at 0 and then increment it based on the info returned in
lpBuffer (i.e. look up MEMORY_BASIC_INFORMATION).

2.
I will collect sets of memory regions with different attributes. However,

I
do not know how to interpret these sets.
Furthermore, I guess I will end up with the same amount of memory, which
"Process viewer" is presenting.


Yes, but this will give you more info than a simple sum. To understand what
you're being given again see MEMORY_BASIC_INFORMATION.

BTW, what failture code to you get from the allocation functions that you
call?

HTH,
Nick


  #64  
Old February 6th 04, 07:59 AM
Nick Savoiu
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

"Klaus Bonadt" wrote in message
...
It seems that you could have that case. You could try to walk the

virtual
address space and see what's going on. Check out VirtualQueryEx().


DWORD VirtualQuery(
LPCVOID lpAddress, // address of region
PMEMORY_BASIC_INFORMATION lpBuffer, // information buffer
SIZE_T dwLength // size of buffer
);

Two questions:
1.
How to set lpAddress initially?


You can start it at 0 and then increment it based on the info returned in
lpBuffer (i.e. look up MEMORY_BASIC_INFORMATION).

2.
I will collect sets of memory regions with different attributes. However,

I
do not know how to interpret these sets.
Furthermore, I guess I will end up with the same amount of memory, which
"Process viewer" is presenting.


Yes, but this will give you more info than a simple sum. To understand what
you're being given again see MEMORY_BASIC_INFORMATION.

BTW, what failture code to you get from the allocation functions that you
call?

HTH,
Nick


  #65  
Old February 6th 04, 08:00 AM
Stephen Howe
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

Thanks a lot, Igor, I got it!

Which container types of the STL are you using Klaus?
And which version of VC++ are you using?

Stephen Howe


  #66  
Old February 6th 04, 08:01 AM
Klaus Bonadt
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

Xref: kermit microsoft.public.vc.language:144422 microsoft.public.vc.stl:18899 microsoft.public.windowsxp.perform_maintain:155681

Which container types of the STL are you using Klaus?
And which version of VC++ are you using?


In first place I use map and vector with VC++ version 6 with some header
replacements.

Regards,
Klaus


  #67  
Old February 6th 04, 08:07 AM
Ivan Brugiolo [MSFT]
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

One other tool useful for a meaningful dump of the process address space
is the '!address' command in cdb/ntsd/windbg.
If will also try to give the usage of the allocated regions, their size,
flags, etc, etc.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Klaus Bonadt" wrote in message
...
It seems that you could have that case. You could try to walk the

virtual
address space and see what's going on. Check out VirtualQueryEx().


DWORD VirtualQuery(
LPCVOID lpAddress, // address of region
PMEMORY_BASIC_INFORMATION lpBuffer, // information buffer
SIZE_T dwLength // size of buffer
);

Two questions:
1.
How to set lpAddress initially?

2.
I will collect sets of memory regions with different attributes. However,

I
do not know how to interpret these sets.
Furthermore, I guess I will end up with the same amount of memory, which
"Process viewer" is presenting.

Regards,
Klaus




  #68  
Old February 6th 04, 08:07 AM
Ivan Brugiolo [MSFT]
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

One other tool useful for a meaningful dump of the process address space
is the '!address' command in cdb/ntsd/windbg.
If will also try to give the usage of the allocated regions, their size,
flags, etc, etc.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Klaus Bonadt" wrote in message
...
It seems that you could have that case. You could try to walk the

virtual
address space and see what's going on. Check out VirtualQueryEx().


DWORD VirtualQuery(
LPCVOID lpAddress, // address of region
PMEMORY_BASIC_INFORMATION lpBuffer, // information buffer
SIZE_T dwLength // size of buffer
);

Two questions:
1.
How to set lpAddress initially?

2.
I will collect sets of memory regions with different attributes. However,

I
do not know how to interpret these sets.
Furthermore, I guess I will end up with the same amount of memory, which
"Process viewer" is presenting.

Regards,
Klaus




  #69  
Old February 6th 04, 08:13 AM
Klaus Bonadt
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

I mean what I said - address space. Each process is allocated a flat 4GB
address space - that's as much as you can address with a 32-bit pointer.
Upper 2GB are reserved for the system (note - this does not mean the
system uses up 2GB of RAM, it just means that you cannot allocate memory
with an address in the upper 2GB). The bottom 2GB are partially occupied
by your executable code and any DLLs it may load. The rest is available
for allocation.


Thus, each process is able to allocate 2GB at maximum. Indeed, I can almost
allocate 2GB with my test program, allocating chunks of 1MB.
However, when my crucial application runs out of memory, Task Manager tells
that there is only 1,6GB in use (see my first mail). Furthermore, starting
my test program at this point in time, this program is able to allocate
further 1,2 GB until my whole virtual memory is allocated. Thus, all other
processes (system and my application) share 3GB - 1,2GB = 1,8GB. One more
indication that my crucial application was still not be able to allocate
nearly 2GB.

My question is, why could my application allocate only 1,4GB (this is what
Process Viewer (Dev Studio6 tools) says) although it should be able to
allocate 2GB.

Now, with very large amounts of RAM, it may so happen that the process
runs out of addresses before it runs out of physical memory (in fact, if
you have more than 2GB of RAM you simply cannot address it all as a flat
space). That's the primary motivation for moving to 64bit processors.


I have the AMD 64 processor, but I need a special 64-bit XP system, which is
not yet available for AMD, correct?

Even if you have enough address space, it may be fragmented. That is,
there are many small stretches of unused address space, but none large
enough to accomodate your allocation request.


What are PVIEW and Task Manager showing, the sum of heap sizes (including
unused space due to fragmentation) or the sum of actual allocated memory
(HeapAlloc) which was not freed afterwards?
I guess the first case, which means the sum of memory which is reserved for
the process even the process is not able to allocate due to fragmentation?
But anyway, as I have mentioned above there must be at least 2 - 1,8 = 0,2GB
unfragmented memory available, otherwise my test program could not allocate
1,2GB until the whole virtual memory is occupied.

Does it mean something like "page handles"? Maybe this number is

restricted?

Maybe there is another limiting resource, for instance the amount of allocs.
I just wrote another test program to clarify this. The test program
allocates only 2Bytes with HeapAlloc() in a loop. It was able to allocate
133,164,202 * 2Bytes = 266,328,404 Bytes, which is 254MB. However, process
viewer shows for this process a heap usage of 2080848KB, which is almost
2GB.
It seems that for every HeapAlloc there are 8 Bytes additional costs in
terms of memory, but the number of allocations
seem to be not limited.

Regards,
Klaus


  #70  
Old February 6th 04, 08:13 AM
Nick Savoiu
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

"Klaus Bonadt" wrote in message
...
I have the AMD 64 processor, but I need a special 64-bit XP system, which

is
not yet available for AMD, correct?


You can download a preview version for free from the MS site.

But anyway, as I have mentioned above there must be at least 2 - 1,8 =

0,2GB
unfragmented memory available, otherwise my test program could not

allocate
1,2GB until the whole virtual memory is occupied.


Each process has a separate virtual address space so fragmentation in one
would not affect another.

It seems that for every HeapAlloc there are 8 Bytes additional costs in
terms of memory, but the number of allocations
seem to be not limited.


Of course. The OS needs to do some bookkeeping for each allocation.

Nick


  #71  
Old February 6th 04, 08:13 AM
André Pönitz
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

In microsoft.public.vc.stl Nick Savoiu
wrote:
"Klaus Bonadt" wrote in message
...
I have the AMD 64 processor, but I need a special 64-bit XP system,
which is not yet available for AMD, correct?


You can download a preview version for free from the MS site.

But anyway, as I have mentioned above there must be at least 2 - 1,8
= 0,2GB unfragmented memory available, otherwise my test program
could not allocate 1,2GB until the whole virtual memory is
occupied.


Each process has a separate virtual address space so fragmentation in
one would not affect another.


It might be a bit off-topic by now, but what is the largest chunk of
'flat memory' I can expect to get on a 32bit Intel system stuffed with
e.g. 3GB of RAM and running not much else than XP?

Andre'
  #72  
Old February 6th 04, 08:13 AM
Igor Tandetnik
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

"Klaus Bonadt" wrote in message
...
Thus, each process is able to allocate 2GB at maximum. Indeed, I can

almost
allocate 2GB with my test program, allocating chunks of 1MB.
However, when my crucial application runs out of memory, Task Manager

tells
that there is only 1,6GB in use (see my first mail).


That's why I think there's fragmentation at work. Imagine the
pathological scenario: your whole memory is occupied by 1K allocated
chunk followed by 1023K free chunk, and so on. 1024 such pairs will eat
up 1GB of RAM in a way that only 1MB is actually used, but you cannot
allocate another 1MB chunk. It's an artificial example of course, it's
highly unlikely to occur in practice, but it demonstrates the idea of
fragmentation nicely.

Furthermore, starting
my test program at this point in time, this program is able to

allocate
further 1,2 GB until my whole virtual memory is allocated.


Your test program is a separate process that has its own address space.
Remember - you are not running out of physical RAM, you are running out
of addresses to map it to. Each process has its very own 4GB address
space, independent of any other process. Physical RAM gets mapped to a
process' address space on as-needed basis.

By the way, with Windows virtual memory management, you cannot fragment
physical memory at all, you can only fragment virtual address space. The
way it works, all physical memory is broken into pages 4KB (on some
systems 8KB) large. So is virtual memory. When a region of virual memory
is allocated, each page of virtual memory is backed by a page of
physical memory. Now, virtual addresses within this region need to be
consequtive (because your program expects the address arithmetic to
work), but physical RAM pages don't need to be. The system just picks
free RAM pages lying around and maps them to virtual pages. Moreover, if
the system runs out of RAM, it picks a physical page (mapped to some
virtual page in some process A), saves its contents to disk and reuses
it for another virtual page possibly in a different process B. If
process A later needs to refer to that virtual page, some other physical
page may be assigned to it and contents read back from disk.

Bottom line: there is no permanent attachment of virtual addresses to
physical RAM pages, and there is no requirement that a contiguous
stretch of virtual addresses be backed by a contiguous stretch of
physical addresses. Thus RAM cannot become fragmented, but virtual
address space can.

I have the AMD 64 processor, but I need a special 64-bit XP system,

which is
not yet available for AMD, correct?


Sorry, I don't know.

Even if you have enough address space, it may be fragmented. That

is,
there are many small stretches of unused address space, but none

large
enough to accomodate your allocation request.


What are PVIEW and Task Manager showing, the sum of heap sizes

(including
unused space due to fragmentation) or the sum of actual allocated

memory
(HeapAlloc) which was not freed afterwards?


I believe they show a working set, which is memory that is a) actually
allocated and b) actually loaded in RAM, rather than being swapped to
hard drive. Well, in your case of huge amounts of RAM available, you can
assume that a working set is very close to actual RAM consumption. They
don't show the unused space, because it is, well, unused.

I guess the first case, which means the sum of memory which is

reserved for
the process even the process is not able to allocate due to

fragmentation?

If this were the case, they would always show 2GB - that's the amount of
address space given to every process. Such a display would be pretty
useless, don't you think?
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


  #73  
Old February 6th 04, 08:13 AM
Klaus Bonadt
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

I mean what I said - address space. Each process is allocated a flat 4GB
address space - that's as much as you can address with a 32-bit pointer.
Upper 2GB are reserved for the system (note - this does not mean the
system uses up 2GB of RAM, it just means that you cannot allocate memory
with an address in the upper 2GB). The bottom 2GB are partially occupied
by your executable code and any DLLs it may load. The rest is available
for allocation.


Thus, each process is able to allocate 2GB at maximum. Indeed, I can almost
allocate 2GB with my test program, allocating chunks of 1MB.
However, when my crucial application runs out of memory, Task Manager tells
that there is only 1,6GB in use (see my first mail). Furthermore, starting
my test program at this point in time, this program is able to allocate
further 1,2 GB until my whole virtual memory is allocated. Thus, all other
processes (system and my application) share 3GB - 1,2GB = 1,8GB. One more
indication that my crucial application was still not be able to allocate
nearly 2GB.

My question is, why could my application allocate only 1,4GB (this is what
Process Viewer (Dev Studio6 tools) says) although it should be able to
allocate 2GB.

Now, with very large amounts of RAM, it may so happen that the process
runs out of addresses before it runs out of physical memory (in fact, if
you have more than 2GB of RAM you simply cannot address it all as a flat
space). That's the primary motivation for moving to 64bit processors.


I have the AMD 64 processor, but I need a special 64-bit XP system, which is
not yet available for AMD, correct?

Even if you have enough address space, it may be fragmented. That is,
there are many small stretches of unused address space, but none large
enough to accomodate your allocation request.


What are PVIEW and Task Manager showing, the sum of heap sizes (including
unused space due to fragmentation) or the sum of actual allocated memory
(HeapAlloc) which was not freed afterwards?
I guess the first case, which means the sum of memory which is reserved for
the process even the process is not able to allocate due to fragmentation?
But anyway, as I have mentioned above there must be at least 2 - 1,8 = 0,2GB
unfragmented memory available, otherwise my test program could not allocate
1,2GB until the whole virtual memory is occupied.

Does it mean something like "page handles"? Maybe this number is

restricted?

Maybe there is another limiting resource, for instance the amount of allocs.
I just wrote another test program to clarify this. The test program
allocates only 2Bytes with HeapAlloc() in a loop. It was able to allocate
133,164,202 * 2Bytes = 266,328,404 Bytes, which is 254MB. However, process
viewer shows for this process a heap usage of 2080848KB, which is almost
2GB.
It seems that for every HeapAlloc there are 8 Bytes additional costs in
terms of memory, but the number of allocations
seem to be not limited.

Regards,
Klaus


  #74  
Old February 6th 04, 08:14 AM
Nick Savoiu
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

"Klaus Bonadt" wrote in message
...
I have the AMD 64 processor, but I need a special 64-bit XP system, which

is
not yet available for AMD, correct?


You can download a preview version for free from the MS site.

But anyway, as I have mentioned above there must be at least 2 - 1,8 =

0,2GB
unfragmented memory available, otherwise my test program could not

allocate
1,2GB until the whole virtual memory is occupied.


Each process has a separate virtual address space so fragmentation in one
would not affect another.

It seems that for every HeapAlloc there are 8 Bytes additional costs in
terms of memory, but the number of allocations
seem to be not limited.


Of course. The OS needs to do some bookkeeping for each allocation.

Nick


  #75  
Old February 6th 04, 08:14 AM
Klaus Bonadt
external usenet poster
 
Posts: n/a
Default No memory although more than 1GB free

Xref: kermit microsoft.public.vc.language:144401 microsoft.public.vc.stl:18865 microsoft.public.windowsxp.perform_maintain:155619

But anyway, as I have mentioned above there must be at least 2 - 1,8 =

0,2GB
unfragmented memory available, otherwise my test program could not

allocate
1,2GB until the whole virtual memory is occupied.


Each process has a separate virtual address space so fragmentation in one
would not affect another.


In my current situation, my application runs out of memory due to a memory
claim of 0.5MB RAM.
Let us assume this is due to fragmented memory, i.e. there is no contiguous
range with more than 0.5MB RAM in the lower 2 GB of virtual address space.
The application stops with popping a message box.
Now I start another application, which allocates in a loop chunks of memory,
each chunk is 1MB. The application does this up to 1.2 GB RAM. I have 3 GB
RAM in total (fixed 1 GB page size). Thus, there was 3 - 1.2 = 1.8GB for my
crucial application plus operating system.
Even the operating system does not need any memory, there are at least 2GB -
1.8GB = 0.2GB in the lower address space available with memory chunks
greater or equal 1MB (otherwise the test program would not be able to
allocate in this area 1MB chunks)!

Excuse me for my questions, but I still do not understand what is going on.

It seems that for every HeapAlloc there are 8 Bytes additional costs in
terms of memory, but the number of allocations
seem to be not limited.


Of course. The OS needs to do some bookkeeping for each allocation.


OK, but 133,164,202 allocations is probably more than enough, it is
sufficient for allocating the maximum number of chunks with 2Byte size.
Only when freeing memory does not result in a free'd entry in the book, this
could be a limited resource. I could try to simulate memory fragmentation
with my test program.

Thanks for your patience with me!
Regards,
Klaus


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off






All times are GMT +1. The time now is 10:34 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PCbanter.
The comments are property of their posters.