Page 1 of 1

Measure RAM

Posted: Tue Apr 30, 2024 7:17 am
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)?

Re: Measure RAM

Posted: Tue Apr 30, 2024 8:36 am
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

Re: Measure RAM

Posted: Tue Apr 30, 2024 1:30 pm
by Stefan
Thank you!