Everybody, thanks for reading and Robert and Sarah for replying.

  • Yes, GetGlobalSizeBySubscript returns Allocated Size only
  • Changing the third GetGlobalSizeBySubscript argument to an empty one does not make a difference in returned Size.
  • GetGlobalSize and ^%GSIZE return Used Size which is still different but not dramatically.
  • I also found an bug in my code. The lengthy InterSystems instructions to the GetGlobalSizeBySubscript code mention: ""Size - Maximum number of MB to count...Be careful to RESET this for multiple calls to the method". I'd say such a Size definition is counterintuitive but at least I got totalSize=1321.57, very close to the result from GetGlobalSize from GetGlobalSizeBySubscript(path,global,global,.Size). Final code with results is:

partialGlobalsSize(dir,global)
sub="",path="C:\Cachesys\mgr\"_dir_"\",searchGlobal="^"_global,Alloc=0,Size=0
x=##Class(%GlobalEdit).GetGlobalSize(path, global,.Alloc,.Size)
global,",",Alloc,",",Size,!  Alloc=1312,725 here, Size=725
Size=0
x=##Class(%GlobalEdit).GetGlobalSizeBySubscript(path,global,"",.Size)
global,",",Size,! 1311.9 here
totalSize=0
F  {
    /// Size - Maximum number of MB to count. If the size of the global exceeds this value,
    /// calculation stops, and an error is returned. If undefined or set to 0, then the entire range is counted.
    /// Be careful to RESET this for multiple calls to the method
    Size=0 ; Resetting!
    sub=$O(@searchGlobal@(sub)) Q:sub="" ;$D(@("^MSCG("_t_")"))
    x=##Class(%GlobalEdit).GetGlobalSizeBySubscript(path,global_"("""_sub_""")","",.Size)
    totalSize=totalSize+Size
}
global,",",totalSize,! 1321.57 here
Q

That's the code I ended up with. Thanks for your help, everybody!

 ; str is parsed into two arrays, words and separators (spaces and punctuation)
 ; Trim leading and trailing spaces here if needed
 L=$L(str),(currWord,currSep)="",cnt=0
 i=1:1:{
  S currChar=$E(str,i,i)
  I $MATCH(currChar,"\w") {
     currWord=currWord_currChar
     currSep'="" {
       sepAr(cnt)=currSep,currSep=""
   }
}
  ELSE {
   currSep=currSep_currChar 
   currWord'="" {
     cnt=cnt+1,wordAr(cnt)=currWord,currWord=""
   }
  }
 }

One late addition: I just lost this debugging functionality again, looks like because my code was going into a different namespace via zn "nsp". If I put the first breakpoint AFTER this zn, the cursor does not go to it and the yellow box does not appear. However, if I put my first breakpoint AT zn, the yellow box appears at it and stays with me after the breakpoint as well. Can't say it's a feature but then what?? smiley

Losing debugging capabilities, Scenario #2.
A fellow programmer also lost her debugging capabilities some time ago though for different reasons and with different symptoms. I am not dead sure what happened in her case but it looks like some unfortunate combination of User Roles and Service Settings as defined in Management Portal. We discussed it today and she tried a few things. Changing the studio login user helped as well as changing localhost in Cache Server Manager to an actual IP address. Using Remote System Access from the cube was beneficial as well.

Alright, this particular saga suddenly came to the end revealing the bug, my own one. But it is sort of educational so some details. I am implementing source control like features on and off while inheriting one of the features from a previous programmer. The latter feature which I preserved was about adding a timestamp with the compilation time to the changed routine in the overwritten source control method, OnAfterCompile. OnAfterCompile was adding this timestamp, resaving the routine  directly in one of the internal routine globals, and it did NOT recompile the file again. That effectively still had the file internally marked as saved and compiled, no little cross in the Studio's routine tab, BUT that threw the .OBJ file mapping to the routine source code enough so the debug yellow box would refuse to appear and the cursor would not move from the first line. Many self eye-rolling emojis here...

How did I discover it? I need to modify this custom source control class and it was annoying to do so while the source control was on so I turned it off, moved functionality to my test routine, and observed with incredulity the long lost yellow debug box again....

P.S. On the plus side, I learned a lot about inner Cache workings due to this largely self-inflicted wound and I am happy it is over.

Everybody, thanks for your help and advice but the old-timer's advice to go the d ^%GOF route in Cache Terminal proved to be it. It was actually amazing to see how much superior this route turned out to be comparing with the much more modern Export/Import Management Portal route. Specifically:

  1. Preparation to exclude certain globals, few dozens of them: Terminal - about 10 minutes because you can use ranges (see below and here, https://docs.intersystems.com/priordocexcerpts/prgglobalchui-41.pdf), portal - much longer because you have to uncheck each global individually
  2. Export speed: Terminal - 10 minutes, portal 3 hours (no kidding)
  3. Export/Import log per global: Terminal - log provided, complete with the number of blocks per global, portal - no log
  4. Import speed: Terminal - less than 10 minutes, portal - stuck in the middle with no error shown

Sample %GOF usage in terminal, hit Enter if no special requests, exporting:
d ^%GOF
Device: tmp.gof
           file format: ("UNW*") =>
          Maximum media size (bytes): (No maximum)
Enter a short description of the contents of this tape or file
Description:
All Globals? No => No
Global ^S-SZ         [All globals in this range, case-sensitive - AG]
Global ^'STPL*     [Exclude all globals that start with STPL - AG]

Real life output from my real life usage:
...............
^ZPG                                           182 data blocks written
^ZTEMP                                           1 data block written
491,337 blocks written in 10 minutes,  51 seconds
--------------------
Importing was done via d ^%GIF, via terminal as well. At some point the %GIF utility asked me:

Globals with a preceding asterisk ('*') already exist in this directory
What would you like to do with these globals that exist?
 
1. Skip inputting globals that exist in this directory
2. Merge input globals with the existing globals
3. Specify skip/merge for individual globals
 
Your choice: 1=>

Thanks again,
Anna

It looks like  code below would give me what I am looking for. Just need to figure out (or take an advice!) how to exclude, say, system classes outright. 

rs=##class(%ResultSet).%New("%Dictionary.ClassDefinitionQuery:ClassIndex")
x=rs.Execute()
f  {
x=rs.Next() q:'x
TimeChanged=rs.GetDataByName("TimeChanged")
ClassName=rs.GetDataByName("ClassName")
Hash1=rs.GetDataByName("Hash1")
Hash2=rs.GetDataByName("Hash2")
System=rs.GetDataByName("System")
ClassType=rs.GetDataByName("ClassType")
Size=rs.GetDataByName("Size")
}
P.S. Found the answer to my last question: https://cedocs.intersystems.com/latest/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=%25Library.RemoteResultSet