My program will throw an OutofMemoryException after run for 30 minutes. Below is how my program works.
I have a button in my form. There is a loop in my button and in that loop, it will create instance of a class and create Thread and assign a sub in the instance to run as multi-threading.
I set the instance to Nothing within the loop. and try to call the Collect() function in garbage collector. But when my program run for few minutes, it still will stop because of out of memory problem.
I tried to create a while loop in the loop above and hope it will slow down the speed of the loop so that the program has enough time to clean the memory but it does not work as well.
Could you tell me how to clear the memory or any other methods to solve this problem? Thanks first for your reply.