I Google the author name of the paper Scott Hanson and he has a profile on Twitter.. You may want to try your luck there.
Original Message:
Sent: Wed June 19, 2024 03:13 AM
From: Matthias Schatte
Subject: Heap analyze on IBM i
Hello,
thanks for the PDF. I know the debug Heap. But this is mostly used to check overwrites of allocated memory segments or the access of already freed memory segments.
Excerpt from the PDF file:
The debug memory manager does not detect memory leaks. Detecting memory leaks within the ILE applications is a topic to be covered in a future article.
Do you know if this article already exists?
------------------------------
Matthias Schatte
Original Message:
Sent: Tue June 18, 2024 09:45 PM
From: Satid S
Subject: Heap analyze on IBM i
This IBM Paper (PDF file) discusses how to properly use heap memory in IBM i ILE languages: Debug those mysterious problems with your application's memory at https://www.ibm.com/support/pages/system/files/inline-files/i-mysterious_application-pdf.pdf. It appears to encourage the use of IBM i heap memory manager: https://www.ibm.com/docs/en/i/7.3?topic=considerations-heap-memory. There are 3 types of IBM i memory manager for different purposes. I also attach the PDF file herewith.
This blog post explains the use of IBM i debug memory manager: Debug Heap-Usage Problems at https://dawnmayi.com/2010/08/02/debug-heap-usage-problems/
------------------------------
Satid S
Original Message:
Sent: Tue June 18, 2024 04:39 AM
From: Matthias Schatte
Subject: Heap analyze on IBM i
In the meantime I have checked some more outfiles an now I can join with file QAYPEIAD and have 16 call stack entries:
CREATE
or
replace
VIEW
mattrc/heapv1
AS
(
SELECT
a.QRECN, a.QHPASA, a.QHPASZ, a.QHPOPR, a.QHPRET,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY16 = QPRKEY) cs16, QIASTMT16,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY15 = QPRKEY) cs15, QIASTMT15,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY14 = QPRKEY) cs14, QIASTMT14,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY13 = QPRKEY) cs13, QIASTMT13,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY12 = QPRKEY) cs12, QIASTMT12,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY11 = QPRKEY) cs11, QIASTMT11,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY10 = QPRKEY) cs10, QIASTMT10,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY9 = QPRKEY) cs9 , QIASTMT9,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY8 = QPRKEY) cs8 , QIASTMT8,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY7 = QPRKEY) cs7 , QIASTMT7,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY6 = QPRKEY) cs6 , QIASTMT6,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY5 = QPRKEY) cs5 , QIASTMT5,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY4 = QPRKEY) cs4 , QIASTMT4,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY3 = QPRKEY) cs3 , QIASTMT3,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY2 = QPRKEY) cs2 , QIASTMT2,
(
select
rtrim(QPRPGN)||
':'
||QPRPNM
from
mattrc/QAYPEPROCI
where
QIAKEY1 = QPRKEY) cs1 , QIASTMT1
FROM
mattrc/QAYPEHEAP a
LEFT
JOIN
mattrc/QAYPEIAD b
ON
a.QRECN = b.QRECN);
But 16 entries for the call stack is also too low for many C++ applications.
------------------------------
Matthias Schatte
Original Message:
Sent: Tue June 18, 2024 02:24 AM
From: Matthias Schatte
Subject: Heap analyze on IBM i
Thanks for your reply.
Sorry, I did not wrote what language we are using. We are using ILE C++ with target release V7R3M0 and newer.
So we can not use the Java analyze tools.
------------------------------
Matthias Schatte
Original Message:
Sent: Mon June 17, 2024 10:27 PM
From: Satid S
Subject: Heap analyze on IBM i
Another tool I also use is IBM i Performance Data Investigator (PDI) charts named IBM Technology for Java Memory Overview and IBM Technology for Java Memory by Job.
The Overview chart helps me see if I should allocate more memory, and about how much more, to the memory pool in which Java jobs are running. This chart shows a total heap size in all pools.
The By Job chart may point out any particular job causing a need for more allocated heap size. You need to be aware which job run in which memory pool. For each job, the red bar exceeding the blue bar is one sign of memory issue.
![](https://dw1.s81c.com//IMWUC/MessageImages/412b990c79e4486498692bca95a6aca3.png)
![](https://dw1.s81c.com//IMWUC/MessageImages/26d40213171d4766bf67d67a268fbd06.png)
------------------------------
Satid S
Original Message:
Sent: Mon June 17, 2024 07:50 AM
From: Matthias Schatte
Subject: Heap analyze on IBM i
Hello,
I have to analyze a memory leak in our software running on IBM i. For that I use the following PEX commands:
ADDPEXDFN DFN(HEAP) TYPE(*TRACE) JOB((123456/MAT/MAT0 *ALL)) TASK(*ALL) MAXSTG(4000000) TRCTYPE(*SLTEVT) SLTEVT(*YES) MCHINST(*NONE) STGEVT((*ACTGRPHEAP))STRPEX SSNID(HEAP)- Do something in the job -ENDPEX SSNID(HEAP) DTALIB(MATTRC) RPLDTA(*YES)
Then I have some outfiles which can be joined together to get the heap address, allocated size and call stack:
CREATE VIEW mattrc/heapv1 AS (SELECT a.QRECN, a.QHPASA, a.QHPASZ, a.QHPOPR, a.QHPRET,-- c.QTITIMN, (SELECT QPRPNM FROM mattrc/QAYPEPROCI WHERE QHPCK1 = QPRKEY) cs1, QIASTMT1, (SELECT QPRPNM FROM mattrc/QAYPEPROCI WHERE QHPCK2 = QPRKEY) cs2, QIASTMT2, (SELECT QPRPNM FROM mattrc/QAYPEPROCI WHERE QHPCK3 = QPRKEY) cs3, QIASTMT3, (SELECT QPRPNM FROM mattrc/QAYPEPROCI WHERE QHPCK4 = QPRKEY) cs4, QIASTMT4, (SELECT QPRPNM FROM mattrc/QAYPEPROCI WHERE QHPCK5 = QPRKEY) cs5, QIASTMT5 FROM mattrc/QAYPEHEAP a INNER JOIN mattrc/QAYPETIDX c ON a.QRECN = c.QRECN LEFT JOIN mattrc/QAYPEIAD d ON a.QRECN = d.QRECN); /* Check mallocs whithout free */ SELECT * FROM mattrc/heapv1 WHERE QHPOPR = 0 AND QHPASA NOT IN(SELECT QHPASA FROM mattrc/heapv1 WHERE QHPOPR = 1);
My problem is, that the outfile QAYPEHEAP has only 5 fields to save 5 call stack entries. Is there a way to get more entries of the call stack?
How do you analyze memory (heap) leaks on IBM i?
On Windows we use WPA (Windows Performance Analyzer) for that.
Thanks and best regards,
Matthias
------------------------------
Matthias Schatte
------------------------------