Hello, I need two informations for my programs under BB: the amount of available ram and the number of processors. I think that AosBoot.memTop gives the first answer. Is there a more portable way to get this information? I don't know where I can get the second answer. AosProcessors.allProcessors seems interesting, but it is not exported. So... Thanks for clues. Gérard
Hello,
I need two informations for my programs under BB: the amount of available ram and the number of processors.
I think that AosBoot.memTop gives the first answer. Is there a more
Hi Gerard, this are the two procedures I use in the JVM to retrieve the memory size and the free memory. PROCEDURE totalMemory*(): LONGINT; VAR total, low, high: LONGINT; BEGIN AosMemory.GetFreeK(total, low, high); RETURN 1024 * total END totalMemory; PROCEDURE freeMemory*(): LONGINT; VAR total, low, high, free, largest: LONGINT; BEGIN AosHeap.GetHeapInfo(total, free, largest); AosMemory.GetFreeK(total, low, high); RETURN free+1024*(low+high) END freeMemory; -Patrik ----- Original Message ----- From: "Gérard Meunier" <gmeunier@club-internet.fr> To: <oberon@inf.ethz.ch> Sent: Friday, January 31, 2003 1:30 AM Subject: [Oberon] Ram & processors portable
way to get this information?
I don't know where I can get the second answer. AosProcessors.allProcessors seems interesting, but it is not exported. So...
Thanks for clues.
Gérard
-- Oberon@inf.ethz.ch mailing list for ETH Oberon and related systems http://www.lists.inf.ethz.ch/mailman/listinfo/oberon
----- Original Message ----- From: Patrik Reali <reali@acm.org> To: <oberon@inf.ethz.ch> Sent: Saturday, February 01, 2003 11:31 PM Subject: Re: [Oberon] Ram & processors
Hi Gerard,
this are the two procedures I use in the JVM to retrieve the memory size and the free memory.
PROCEDURE totalMemory*(): LONGINT; VAR total, low, high: LONGINT; BEGIN AosMemory.GetFreeK(total, low, high); RETURN 1024 * total END totalMemory;
PROCEDURE freeMemory*(): LONGINT; VAR total, low, high, free, largest: LONGINT; BEGIN AosHeap.GetHeapInfo(total, free, largest); AosMemory.GetFreeK(total, low, high); RETURN free+1024*(low+high) END freeMemory;
-Patrik
Thank you Patrick, In fact, I want to estimate which amount of memory I can allocate on the heap without disturbing too much other applications. Which is the most pertinent "free" value for starting calculus? The value from your FreeMemory procedure or the value from GetHeapInfo? Is the memory in "low" and "high" parameters allocatable? I suppose it's reserved for the stack, isn't it? Regards. Gérard
From: "Gérard Meunier" In fact, I want to estimate which amount of memory I can allocate on the heap without disturbing too much other applications. Which is the most pertinent "free" value for starting calculus? The value from your FreeMemory procedure or the value from GetHeapInfo? Is the memory in "low" and "high" parameters allocatable? I suppose it's reserved for the stack, isn't it?
AosHeap.GetHeapInfo(total, free, largest); largest gives you the currently largest allocable block in memory (due to fragmentation this is less than the total free heap memory). It is usually possible to allocate more, because the memory manager can start a garbage collection to reclaim unused memory blocks, and in case of need it can also add memory pages to the heap. The number of free pages can be asked with AosMemory.GetFreeK. This pages are used for stacks and heap. Stack pages can be reclaimed, whereas heap pages are allocated "forever". If you run many active object you should be careful not to overallocate, otherwise you may run out of pages for the stacks. This is rare but may happen (I experienced this when running some big benchmarks on the JVM and afterwards compiling with Paco). The details about page allocation (and some restrictions like the maximum number of memory pages used for the heap) can be found in Pieter Muller's thesis (page 65, Interaction with the page heap). -Patrik
From: Patrik Reali The number of free pages can be asked with AosMemory.GetFreeK. This pages are used for stacks and heap.
Ok. I begin to understand. I'll try to summarize. At the start, only a small heap is allocated. This heap, when full, will grow and never shrink. The AosHeap.GetHeapInfo procedure gives data about the allocated heap, whereas AosMemory.GetFreeK gives informations about the yet non-allocated memory, which is divided in two areas: the low memory, below 1Mb (640 kb, more precisely), and the high memory, above 1 Mb. These free pages may also be allocated temporarily to the stack(s). So, your freeMemory procedure gives exactly what I need. What I don't understand is the difference, in the GetFreeK procedure, between the "total" parameter and the sum "low + high". Their values are not equal. Why? Regards. Gérard
From: Patrik Reali The number of free pages can be asked with AosMemory.GetFreeK. This
----- Original Message ----- From: "Gérard Meunier" <gmeunier@club-internet.fr> To: <oberon@inf.ethz.ch> Sent: Monday, February 03, 2003 12:13 AM Subject: Re: [Oberon] Ram & processors pages
are used for stacks and heap.
Ok. I begin to understand. I'll try to summarize. At the start, only a small heap is allocated. This heap, when full, will grow and never shrink. The AosHeap.GetHeapInfo procedure gives data about the allocated heap, whereas AosMemory.GetFreeK gives informations about the yet non-allocated memory, which is divided in two areas: the low memory, below 1Mb (640 kb, more precisely), and the high memory, above 1 Mb. These free pages may also be allocated temporarily to the stack(s). So, your freeMemory procedure gives exactly what I need.
What I don't understand is the difference, in the GetFreeK procedure, between the "total" parameter and the sum "low + high". Their values are not equal. Why?
Total is the total number of pages in the system (including the allocated ones). This value is used to compute how many pages can be allocated to the heap. The current policy is up to 95%, so that at least 5% of the pages are always available to the stacks. -Patrik
What I don't understand is the difference, in the GetFreeK procedure, between the "total" parameter and the sum "low + high". Their values are not equal. Why?
Total is the total number of pages in the system (including the allocated ones).
This value is used to compute how many pages can be allocated to the heap. The current policy is up to 95%, so that at least 5% of the pages are always available to the stacks.
Thanks a lot. I got all answers I needed about memory. About processors: who knows how to get the number of running processors? Thanks in advance. Gérard
participants (2)
-
Gérard Meunier -
Patrik Reali