Monitor Descriptors used (RESOURCE LIMIT EXCEEDED ERROR)

Matthew Roessner
Matthew Roessner used Ask the Experts™
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?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
VP Technology / Senior Consultant
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:

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:

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