I am using VB2012 to create a WinForms application. The Form gives the user the ability to create "pages". Each page has a certain number of questions on it. The questions are survey questions with radio buttons for answers. Depending on how many questions are on a page, if they add too many pages, the program throws an error saying that it can not create the handle. Apparently I have too many open and need to dispose of some.
I need to determine if I am getting close to the limit or not so I can stop the creation of more pages, but I don't know what to check to see how close I am.
BTW, a page is simply a panel with another set of questions on it added to the main panel, so that the panels can be flipped through like pages.
Each question is a class with about 20 objects on it. The limit seems to be about 500 questions total (regardless of the number of pages).
Thanks.
I think the comments give some good advice to the OP, but just to answer the original question:
Process.GetCurrentProcess.HandleCount
Gets the number of handles opened by the process.
Handles provide a way for a process to refer to objects. A process can obtain handles to files, resources, message queues, and many other operating system objects. The operating system reclaims the memory associated with the process only when the handle count is zero.