Monitor Descriptors used (RESOURCE LIMIT EXCEEDED ERROR)

Matthew Roessner
Matthew Roessner used Ask the Experts™
on
We are getting the following error, "Resource limit type 14 exceeded with reason code 542".  When looking at type 14, it says, "If this is error type 14, reduce the number of allocated descriptors with the DEALLOCATE DESCRIPTOR statement."

I was wondering if anyone know how we could monitor our program for how many descriptors are currently being used?

I found we could use the following statement to allocate descriptors, "EXEC SQL ALLOCATE DESCRIPTOR 'NEWDA' WITH MAX 20" - but if we don't know how many we currently have - seems like this isn't going to do much for us.

Any ideas?
QPJOBLOG_1429_QPRTJOB_RHO_832377_S21.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
VP Technology / Senior Consultant
Commented:
This is probably the result of a "descriptor leak" - a coding bug in your program.

In your programs/stored procedures/functions/triggers that ALLOCATE DESCRIPTOR, a good practice is to explicitly DEALLOCATE DESCRIPTOR when you are done with them.  (Just like you should close SQL cursors and deallocate dynamically allocated memory).  Most likely, your process is repeatedly allocating descriptors without deallocating them.   Setting MAX 20 does nothing useful in this is case- 20 is the default.  If you need fewer then 20 parameters in a descriptor, you can reduce the MAX to that number, and you may be able to get more descriptors allocated before it finally crashes, but that really doesn't fix the problem.

Here is an article with a brief explanation of how to use SQL descriptors in embedded SQL in RPG:

https://www.itjungle.com/2015/09/15/fhg091515-story01/

SQL descriptors are also implicitly closed based on the CLOSQLCSR parameter used to compile the program, but make sure you understand the functional and performance impact of recompiling with a different CLOSQLCSR option before you make a change.  See ALLOCATE DESCRIPTOR in the IBM i DB2 SQL Reference for details:

https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/db2/rbafzpdf.pdf

Post the problem code if you want more detailed help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial