# How to limit CPU threads and memory usage in client/server mode

**URL:** https://discourse.paraview.org/t/how-to-limit-cpu-threads-and-memory-usage-in-client-server-mode/3814
**Category:** Tips and Tricks
**Created:** [March 14, 2020, 3:07pm UTC](https://discourse.paraview.org/t/how-to-limit-cpu-threads-and-memory-usage-in-client-server-mode/3814 "2020-03-14T15:07:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mconti](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mconti/32/2168_2.png) [@mconti](https://discourse.paraview.org/u/mconti)
#### Post date: [March 14, 2020, 3:07pm UTC](https://discourse.paraview.org/t/how-to-limit-cpu-threads-and-memory-usage-in-client-server-mode/3814/1 "2020-03-14T15:07:24Z")

</div>

Hey everyone, as some of you are already aware, when using Paraview with OSPRay enabled in client/server mode if will EAT up memory and CPU usage. We have found that on server side it will eat up 4-5 times the memory it needs and use all CPU’s threads it can. After talks with some Kitware developers there is an easy fix that I figured I would make a bit more well known.

You can pass 2 environmental variables to the server that limit the number of threads that PV/OPSRay can take up. This does two great things in one. First it caps the CPU threads you can grab, but also seems to have a speed increase as well (we believe this is to not having an i/o hit because of constantly changing number of threads). Additionally, it greatly reduces the amount of memory the simulation will take up, although I’m not 100% sure why this is the case.

Thus, if you are using C/S mode (especially with OSPRay enabled), I highly suggest setting these variables to something reasonable. Here is a super simple bash script that does it.

```
#!/bin/bash
NP=$1
export KNOB_MAX_WORKER_THREADS=$NP
export OSPRAY_THREADS=$NP
echo $KNOB_MAX_WORKER_THREADS

```

Hope this helps someone, it has been a big help for my company.
