How can I programmatically obtain the amount of memory an assembler program is currently using assembler instructions/macros from within the running program? I'm debugging an 878 (out of memory) error, and I"d like my program to report at different stages how much memory it is using.
-
1This depends on what OS you are running on and involves calling OS API. – arrowd Nov 29 '17 at 20:54
-
I'm running zos v1.3 – FierceMonkey Nov 29 '17 at 21:35
-
Real or virtual? – zarchasmpgmr Nov 30 '17 at 02:08
-
Wow, z/OS 1.3: End of support 2005-03-31... – piet.t Nov 30 '17 at 07:03
-
I was mistaken, its actualy version 2.1. determining the virtual memory amount would be fine. I'm trying to debug an 878 abend. I'm sure there are other ways to do it, but this is the method I'm interested in learnings about (if it is even possible to do) – FierceMonkey Nov 30 '17 at 14:12
-
Normally one just increases the REGION parameter on the job step. This won't work if a bug has created a runaway `STORAGE OBTAIN` (or `GETMAIN` or `SVC 10` or `CEEGTST`) loop of course but that's an edge case. Sometimes people use their shop's performance profiling utility. This is not to say what you're doing is wrong, it's fine, just uncommon. – cschneid Nov 30 '17 at 14:30
-
They way I debug ABEND878 is to use IPCS `VERBEXIT VSMDATA CONTROLBLOCKS` and look at the `DQE` entries. – David Crayford Dec 05 '17 at 05:14
1 Answers
Region size can be set a variety of different ways depending on the type of address space (TSO session, batch job, STC, ...). Some sites set custom region sizes using an SMF exit, so it's not always easy to understand what's going on here.
The limit value for a given address space is stored in the LDA data area (see https://www-304.ibm.com/servers/resourcelink/svc00100.nsf/pages/zOSV2R3ga320937/$file/iead300_v2r3.pdf). In an assembler program, you'd get this value by following PSAAOLD to ASCBLDA and then examining whatever region size you're looking for.
A more modern interface to this stuff is available in the various UNIX Services APIs on z/OS. For example, getrusage (BPX1GRU) gives you your resource utilization for several resources, including memory. All an assembler program needs to use this stuff is a UNIX UID value in your security information - no other special setup is needed.

- 1,769
- 9
- 29
-
I know what my region limit size is, I am specifying it on the JCL EXEC statement with the REGION=XX parm. i'm not interested in the max memory allowed, but the amount of memory currently allocated by a running program at any given point in time durring its executing. – FierceMonkey Dec 04 '17 at 16:17
-
Valerie's answer is correct. The `LDA` contains the current usage not just the limit. `LDALOAL` is the current private area usage below the 16MB line and `LDAELOAL` is the usage above the 16MB line. – David Crayford Dec 05 '17 at 05:56
-
`BPX1GRU` only seems to return times, not memory usage, unless I'm missing something? – David Crayford Dec 05 '17 at 06:01
-
@FierceMonkey: Small caution: just because you set REGION in your JCL doesn't mean you truly know your region size - there are several ways region size can be overridden depending on how sophisticated your site is. – Valerie R Dec 21 '17 at 18:17
-
@David Crayford: You are correct about the "stock" BPX1GRU...there is a way though - if you really need to know, I'd suggest turning on the SYSOMVS trace and running a "ps" command with the -vsz option - you'll definitely find your answer in the trace output. – Valerie R Dec 21 '17 at 18:19
-
@ValerieR That would require spawning a process and piping the output which is probably overkill. Your original suggestion of chasing control blocks is the optimal solution. – David Crayford Jan 04 '18 at 11:48
-
@David Crayford: I think you misunderstood...there's a poorly documented way to get whet the original poster wanted using BPX1GRU, but you need to know what the magic parameters are. One way to figure that out would be to look at what some existing code does (the "ps -vsz" command) and once you know what that code calls, you can do the same thing. I'm not suggesting calling "ps" as a solution - only as a research tool. :) – Valerie R Feb 04 '18 at 17:58