Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCF/Darwin Memory Statistics
Function:
Required plugins for this example: MBS MacCF Plugin, MBS Main Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCF/Darwin Memory Statistics
This example is the version from Thu, 16th Nov 2016.
Project "Darwin Memory Statistics.rbp"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim i as integer dim p as Picture for i=1 to 250 // 1 GB p = new Picture(1000,1000,32) v.Append p next update End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() dim p as Picture p = new Picture(1000,1000,32) // around 4 MB v.Append p // store it update End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() dim m as MemoryBlock m=NewMemoryBlock(4*1024*1024) // around 4 MB v.Append m // store it update End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control StaticText5 Inherits Label
ControlInstance StaticText5 Inherits Label
End Control
Control StaticText6 Inherits Label
ControlInstance StaticText6 Inherits Label
End Control
Control StaticText7 Inherits Label
ControlInstance StaticText7 Inherits Label
End Control
Control StaticText8 Inherits Label
ControlInstance StaticText8 Inherits Label
End Control
Control StaticText9 Inherits Label
ControlInstance StaticText9 Inherits Label
End Control
Control StaticText10 Inherits Label
ControlInstance StaticText10 Inherits Label
End Control
Control StaticText11 Inherits Label
ControlInstance StaticText11 Inherits Label
End Control
Control StaticText12 Inherits Label
ControlInstance StaticText12 Inherits Label
End Control
Control StaticText13 Inherits Label
ControlInstance StaticText13 Inherits Label
End Control
Control StaticText14 Inherits Label
ControlInstance StaticText14 Inherits Label
End Control
Control PushButton4 Inherits PushButton
ControlInstance PushButton4 Inherits PushButton
EventHandler Sub Action() redim v(-1) update End EventHandler
End Control
Control StaticText15 Inherits Label
ControlInstance StaticText15 Inherits Label
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() update End EventHandler
End Control
EventHandler Sub Open() update End EventHandler
Protected Function FormatMemory(d as double) As string Return Format(d/1024,"-0")+" KB" // if you see a minus, be have an integer problem End Function
Protected Sub update() dim v as DarwinVMStatisticsMBS dim t as DarwinTaskInfoMBS dim p as Double v=GetDarwinVMStatisticsMBS t=new DarwinTaskInfoMBS // constructor fills values p=v.Pagesize // make a double to avoid integer overflow problems StaticText9.text=FormatMemory(SystemInformationMBS.PhysicalRAM) StaticText10.text=FormatMemory(t.ResidentSize) StaticText11.text=FormatMemory(p*v.FreePages) StaticText12.text=FormatMemory(p*v.InactivePages+p*v.ActivePages+p*v.FreePages+p*v.WiredPages) StaticText13.text=FormatMemory(t.VirtualSize) StaticText14.text=FormatMemory(p*v.FreePages) End Sub
Property Protected v() As variant
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() if TargetMachO then // ok else MsgBox "This needs a Mach-O target running on Mac OS X." end if End EventHandler
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCF Plugin.




Links
MBS Xojo Plugins