Monitoring Memory usage

Just starting out? Need help? Post your questions and find answers here.
User avatar
singo
User
User
Posts: 35
Joined: Mon Apr 23, 2007 4:50 am
Location: Nabiac NSW Australia

Monitoring Memory usage

Post 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
Singo
Win10, Win7, Debian x86 & OSX ~ PB 5.70 LTS
Minimbah NSW Australia
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Monitoring Memory usage

Post 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.
User avatar
singo
User
User
Posts: 35
Joined: Mon Apr 23, 2007 4:50 am
Location: Nabiac NSW Australia

Re: Monitoring Memory usage

Post 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
Singo
Win10, Win7, Debian x86 & OSX ~ PB 5.70 LTS
Minimbah NSW Australia
Post Reply