0

Memory Usage after 3-4 functions

Threads after 2 forms open and closed and 2 different processes started one of them is closed

Recently I created a wpf application that will not be stopped by user. I used spy++ to see how many threads are there. The issue is it creates many threads(average all time threads are 15-17 whether app is minimized or not) I have seen upto 23 and when application is minimized those threads are not stopped they are just in wait state (reason - user request), so not freeing the memory. I have tried many things like disposing manually, closing forms and applications. I have not created these threads so I dont know how do I kill these threads.

What I am doing now is when user minimizes the application I am calling close method of other window forms manually. so a little bit of memory is cleaned. My worry is Its minimum 92MB when its doing nothing just sitting in the background. it reaches to 180 MB, If I perform some functions.

Please anyone can advice me on this. How do I stop these threads and free the memory.Please let me know if there is any need of my code related to anything. I will post that. And please before a negative vote have a clarification with me If I have done anything or not.

I have read when people minimize their memory usage decrease upto 5 times sometimes... But its not same here.. The memory uses are near about same.(only 10-30MB freed)

Update: Added screenshots from spy++ . I closed all the forms and only one other processes is running after this. Then also It stayed at 21 threads.

10
  • 1
    These threads probably belong to the ThreadPool Nov 1, 2018 at 9:30
  • Have you looked at Cancellation Tokens?
    – Aman B
    Nov 1, 2018 at 9:43
  • I am looking into both Cancellation Tokens and Thread Pool if I can find something of use. Nov 1, 2018 at 9:44
  • 3
    Ok, you have threads. But do you actually have a problem? What is not functioning, how?
    – bommelding
    Nov 1, 2018 at 9:46
  • @bommelding.. The issue is that the application is going to run on a Multimedia Controlling device that wont have much memory to run large memory using app along with other necessary apps. So I just want to remove as much memory as it can be freed when the application is not doing anything. Nov 1, 2018 at 9:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.