Page 1 of 1

Monitoring Memory usage

Posted: Fri Oct 29, 2010 12:53 pm
by singo
Hi,

I want to monitor the amount of memory available to my program as I setup arrays etc.

I am using functions in Droopys lib and doing a simple test like the following

Code: Select all

Procedure mem()
  Debug GlobalMemoryStatusTotalPhys()
  Debug GlobalMemoryStatusTotalVirtual()

  Debug GlobalMemoryStatusAvailPhys()
  Debug GlobalMemoryStatusAvailVirtual()
  Debug "============"
EndProcedure
mem()
Dim f.s(20000)
mem()
When I run this code the Totals don't change as expected, but either do the Avail after declaring the array.

I must be misunderstanding the way memory works or is allocated OR the functions don't work the way I would expect them to. Can someone explain ?

Thanks Singo
XP SP3, PB 4.51

Re: Monitoring Memory usage

Posted: Fri Oct 29, 2010 2:55 pm
by Demivec
singo wrote:When I run this code the Totals don't change as expected, but either do the Avail after declaring the array.

I must be misunderstanding the way memory works or is allocated OR the functions don't work the way I would expect them to. Can someone explain ?
According to my understanding, at the time the memory is reserved it doesn't actually use physical memory. If it is not used, i.e. by assigning it a value, it doesn't use any physical memory and so shouldn't affect the total available.

To apply this with regard to an array, check the available memory after values are assigned and not at the point of the Dim statement.

Re: Monitoring Memory usage

Posted: Fri Oct 29, 2010 9:25 pm
by singo
Demivec wrote:
singo wrote:When I run this code the Totals don't change as expected, but either do the Avail after declaring the array.

I must be misunderstanding the way memory works or is allocated OR the functions don't work the way I would expect them to. Can someone explain ?
According to my understanding, at the time the memory is reserved it doesn't actually use physical memory. If it is not used, i.e. by assigning it a value, it doesn't use any physical memory and so shouldn't affect the total available.

To apply this with regard to an array, check the available memory after values are assigned and not at the point of the Dim statement.
Thanks Demivec, that does make a difference so I will pursue real time monitoring with values.

Singo
XP PB 4.51