# Memory leak in ray serve 2.1.0

**URL:** <https://discuss.ray.io/t/memory-leak-in-ray-serve-2-1-0/8424>\
**Category:** Ray Serve\
**Created:** [November 24, 2022, 3:01am UTC](https://discuss.ray.io/t/memory-leak-in-ray-serve-2-1-0/8424 "2022-11-24T03:01:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![litttl](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/litttl/32/3484_2.png) [@litttl](https://discuss.ray.io/u/litttl)\
**Post date:** [November 24, 2022, 3:01am UTC](https://discuss.ray.io/t/memory-leak-in-ray-serve-2-1-0/8424/1 "2022-11-24T03:01:21Z")

</div>

**How severe does this issue affect your experience of using Ray?**

- High: It blocks me to complete my task.

I use ray[serve] to deploy my web serve. I found that there are memory leak happened.

I use the single node with the steps：

1. ray start --head
2. python my\_serve.py

the key codes is as following:

* * *

my\_serve.py  
ray.init(address=‘auto’, namespace=‘serve’)  
serve.start(http\_options={‘host’:‘0.0.0.0’, ‘port’:9099}, detached=True)  
MyServe.deploy()

@serve.deployment(name=…, num\_replicas=4, ray\_actor\_options={‘num\_gpus’: 0.1}, route\_prefix=‘/detect’)  
class MyServe:  
def **init** (self):  
…

```
@serve.batch(max_batch_size=16, batch_wait_timeout_s=10)
async def handle_batch(self, flask_requests):
	for flask_request in flask_requests:
		info = await flask_request.json()
		...
	
	return response

async def __call__ (self, request):
	return await self.handle_batch(request)

```

* * *

Could anyone give me some advise?

---

<div class="post-metadata">

**Author:** ![simon-mo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/simon-mo/32/9_2.png) [@simon-mo](https://discuss.ray.io/u/simon-mo)\
**Post date:** [November 28, 2022, 5:24pm UTC](https://discuss.ray.io/t/memory-leak-in-ray-serve-2-1-0/8424/2 "2022-11-28T17:24:03Z")

</div>

We had a recent fix for memory leak in [[Core] Close GCS channel after health check to fix one memory leak in `dashboard.py` by architkulkarni · Pull Request #30346 · ray-project/ray · GitHub](https://github.com/ray-project/ray/pull/30346). Can you please try out the nightly release to see whether the leak still exist? [Installing Ray — Ray 3.0.0.dev0](https://docs.ray.io/en/master/ray-overview/installation.html#daily-releases-nightlies)
