You are here: Surpac Concepts > Macros > SCL > System and Misc > sclMemoryUsage
GEOVIA Surpac

SclMemoryUsage

Overview

This command shows you how much memory Surpac and HOOPS are using. SclMemoryUsage is useful if Surpac is running slowly and you want to work out if the problem is related to memory usage.

Syntax

SclMemoryUsage

Description

All memory values are in bytes.

Arguments

None.

Returns

Returns the following data items:

  • WorkingSetSize. The total amount of memory currently used by Surpac (including HOOPS) in bytes.
  • PeakWorkingSetSize. The largest amount of memory that Surpac (including HOOPS) has used since you started the current Surpac session.
  • PageFaultCount. The number of times Surpac has used a new page of memory.
  • QuotaPagedPoolUsage. The amount of used memory that can be moved to virtual memory if required.
  • QuotaPeakPagedPoolUsage. The largest value of the QuotaPagedPoolUsage in this Surpac session.
  • QuotaNonPagedPoolUsage. The amount of used memory that cannot be moved to virtual memory.
  • QuotaPeakNonPagedPoolUsage. The largest value of the QuotaNonPagedPoolUsage in this Surpac session.
  • PagefileUsage.The amount of virtual memory currently used by Surpac.
  • PeakPagefileUsage. The largest amount of virtual memory that Surpac has used since you started the current Surpac session.
  • hoops_allocated. The amount of memory reserved by HOOPS.
  • hoops_used. The amount of memory currently used by HOOPS. This amount cannot be greater than hoops_allocated.

Code Samples

set memoryStats [SclMemoryUsage]
puts "$memoryStats"

The previous code sample returns text, to the Message window, similar to the following.

WorkingSetSize=169693184, PeakWorkingSetSize=170229760, PageFaultCount=58552, QuotaPagedPoolUsage=500956, QuotaPeakPagedPoolUsage=571052, QuotaNonPagedPoolUsage=64456, QuotaPeakNonPagedPoolUsage=126680, PagefileUsage=186445824, PeakPagefileUsage=187043840, hoops_allocated=3257192, hoops_used=2180800]

 

proc formatMemoryColumns {memoryStats} {
set statsList [split $memoryStats ,]
set statsCount [llength $statsList]
set labels ""
for {set i 0} {$i < $statsCount} {incr i} {
    set label [lindex [split [lindex $statsList $i] =] 0]
    append labels $label ,
    }
return $labels
}
proc formatMemoryStats { memoryStats} {
set statsList [split $memoryStats ,]
set statsCount [llength $statsList]
set values ""
for {set i 0} {$i < $statsCount} {incr i} {
    set value [lindex [split [lindex $statsList $i] =] 1]
    append values $value ,
    }
return $values
}
set memoryStats [SclMemoryUsage]
puts "[formatMemoryColumns $memoryStats]"
puts "[formatMemoryStats $memoryStats]"
						

The previous code sample returns the memory statistics, separated by commas, to the Message window. If you want, you can then copy the output to a text editor, save it as a .csv file and open it in Microsoft ™ Excel.