Monitor Descriptors used (RESOURCE LIMIT EXCEEDED ERROR)

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?
Matthew RoessnerSenior Systems ProgrammerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gary PattersonVP 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:

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.