Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it must to ShutDown/Dispose STP? #29

Open
MatheswaranSagadevan opened this issue Nov 26, 2021 · 3 comments
Open

is it must to ShutDown/Dispose STP? #29

MatheswaranSagadevan opened this issue Nov 26, 2021 · 3 comments

Comments

@MatheswaranSagadevan
Copy link

Hi,
We recently explored STP, and started using it in one of our asp.net core application.
and our implementation is like, during particular object's constructor we configure/instantiate the smart thread pool with work item groups and min, max threads etc.

There are two questions:

  1. We often face outofmemory exceptions, though we have 8 core, 16GB RAM with 1 TB HDD VM. any guidelines or best practices to adept ?
  2. when to use ShutDown and Dispose methods. Since this is a web application, we as said above, configured, in one of our singleton class. so when to dispose? or shutdown?
  3. I tried with destructor and it seems it didn't get called. Then I tried with application stopping event in asp.net core where I retrieve the singleton instance and called custom dispose method to shutdown and dispose stp. is this right approach?

Thanks,
Matheswaran S

@amibar
Copy link
Owner

amibar commented Nov 28, 2021

Hi,

I assume that your application works like a service. Hence, always running and serve requests.

I think you should instatiate the smart thread pool only once in a singleton with min and max threads.
Later on create work item groups with the concurrency you need and queue work items into them.
Since your application work like a service (as I assumed) you don't need to call to shutdown or dispose at all.
When you stop the service you can use WaitForIdle() to wait for incompleted work items to finish.

Regards,
Ami

@MatheswaranSagadevan
Copy link
Author

Great, you are right it is a service. and I'm fine to use WaitForIdle instead of shutdown.

and how about Memory management.? any best practices and troubleshooting tips? because we often face outofmemory exception.

@amibar
Copy link
Owner

amibar commented Nov 29, 2021

The outofmemory exception is out of my scope.
I assume you get the exception becuase you get too many requests than you can handle so the backlog explodes.
Try to limit the backlog to avoid requests overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants