Measure RAM

Just starting out? Need help? Post your questions and find answers here.
Stefan
Posts: 248
Joined: Mon Feb 05, 2018 9:44 pm

Measure RAM

Post by Stefan »

I would like to find out whether my Spiderbasic application is using too much memory.
To do this, I first need to know how much RAM my device has and how much RAM I use.
Is there a way to measure this with Spiderbasic (Javascript)?
User avatar
Peter
Posts: 1197
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Measure RAM

Post by Peter »

I have found this. Maybe it is useful. However, it does not work with Firefox.

Code: Select all

Structure sMemoryInfo
  jsHeapSizeLimit.i
  totalJSHeapSize.i
  usedJSHeapSize.i
EndStructure

Global MemoryInfo.sMemoryInfo

Procedure GetMemoryInfo()
  
  ! if (!window.performance.memory) return; // doesn't work with Firefox
  ! var memoryinfo = window.performance.memory;
  ! g_memoryinfo._jsHeapSizeLimit = memoryinfo.jsHeapSizeLimit;
  ! g_memoryinfo._totalJSHeapSize = memoryinfo.totalJSHeapSize;
  ! g_memoryinfo._usedJSHeapSize= memoryinfo.usedJSHeapSize;
  
EndProcedure

GetMemoryInfo()

Debug "jsHeapSizeLimit: " + MemoryInfo\jsHeapSizeLimit
Debug "totalJSHeapSize: " + MemoryInfo\totalJSHeapSize
Debug "usedJSHeapSize: " + MemoryInfo\usedJSHeapSize
Further informations: https://developer.mozilla.org/en-US/doc ... nce/memory
Stefan
Posts: 248
Joined: Mon Feb 05, 2018 9:44 pm

Re: Measure RAM

Post by Stefan »

Thank you!
Post Reply