I have a really weird problem with one user. He can’t connect to an SQLite database. I traced this back to a pragma where I reserve memory for the database. Then I noticed something odd in the startup sequence. At the very beginning - really before anything is done - I check the available memory.
The data from my Intel iMac looks like this:
2024-05-17 14:34:23 Total physical Memory: 32,000 GB
2024-05-17 14:34:23 Physical Memory used by MAX: 0,127 GB
2024-05-17 14:34:23 Free physical Memory: 0,180 GB
2024-05-17 14:34:23 Total virtual Memory: 31,910 GB
2024-05-17 14:34:23 Virtual Memory used by MAX: 6,657 GB
2024-05-17 14:34:23 Free virtual Memory: 0,180 GB
Now compare this to the M2 of the user:
2024-05-17 12:58:53 Total physical Memory: 16,000 GB
2024-05-17 12:58:53 Physical Memory used by MAX: 0,163 GB
2024-05-17 12:58:53 Free physical Memory: 0,074 GB
2024-05-17 12:58:53 Total virtual Memory: 9,681 GB
2024-05-17 12:58:53 Virtual Memory used by MAX: 394,115 GB
2024-05-17 12:58:53 Free virtual Memory: 0,074 GB
What could cause the 394 GB of virtual memory?
The code for getting the memory information, which is directly out of the MBS examples:
dim theDarwin as DarwinVMStatisticsMBS = GetDarwinVMStatisticsMBS
if theDarwin = nil then Return
dim theTaskInfo as new DarwinTaskInfoMBS
if theTaskInfo = nil then Return
dim thePageSize as Double = theDarwin.Pagesize // make a double to avoid integer overflow problems
LogItem "Total physical Memory: " + FormatMemory(SystemInformationMBS.PhysicalRAM)
LogItem "Physical Memory used by MAX: " + FormatMemory(theTaskInfo.ResidentSize)
LogItem "Free physical Memory: " + FormatMemory(thePageSize * theDarwin.FreePages)
LogItem "Total virtual Memory: " + FormatMemory(thePageSize * theDarwin.InactivePages + thePageSize * theDarwin.ActivePages + thePageSize * theDarwin.FreePages + thePageSize * theDarwin.WiredPages)
LogItem "Virtual Memory used by MAX: " + FormatMemory(theTaskInfo.VirtualSize)
LogItem "Free virtual Memory: " + FormatMemory(thePageSize * theDarwin.FreePages)
The code that fails as result:
SQLiteIndexDBMBS.ExecuteSQL "PRAGMA cache_size = 500000" // 500 MB
SQLiteIndexDBMBS.ExecuteSQL "PRAGMA encoding = ""UTF-8""" // encoding utf8 instead of utf16