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

Why not delete room or peer if they are useless #32

Open
maggch97 opened this issue Nov 25, 2022 · 4 comments
Open

Why not delete room or peer if they are useless #32

maggch97 opened this issue Nov 25, 2022 · 4 comments

Comments

@maggch97
Copy link

type pmap struct {
	sync.RWMutex
	id string
	m  map[string]*Peer
}
type rmap struct {
	sync.RWMutex
	m map[string]*pmap
}

I found the peer and room data in these 2 struct will never be deleted. I think this memory leak is a problem if the service running for a long time. What do you think?

@jadeydi
Copy link
Member

jadeydi commented Nov 25, 2022

There is no limit the number of elements in map in golang. It does occupy more memory if service running for a long time, but the size of a blank map is small, I think there doesn't have much effect.

@maggch97
Copy link
Author

maggch97 commented Nov 26, 2022

There is no limit the number of elements in map in golang. It does occupy more memory if service running for a long time, but the size of a blank map is small, I think there doesn't have much effect.

Sorry, I don't think the effect is small. Below is the info of kraken deployed in my server. There're only 6 active users but 2486 inactive users. The kraken service uses almost 500MB memory. When the service is just started, the memory usage was below 100MB.

The map is not blank also, all Peer struct are not released. But I'm not sure if the memory leak is caused by this.

{
   "data":{
      "updated_at":"2022-11-26T04:02:16.544191438Z",
      "active_peers":6,
      "closed_peers":2486,
      "active_rooms":4,
      "closed_rooms":119
   },
   "id":"1d870674-9329-44f7-b218-e40db615f52c"
}

image

@jadeydi
Copy link
Member

jadeydi commented Nov 26, 2022

There is no limit the number of elements in map in golang. It does occupy more memory if service running for a long time, but the size of a blank map is small, I think there doesn't have much effect.

Sorry, I don't think the effect is small. Below is the info of kraken deployed in my server. There're only 6 active users but 2486 inactive users. The kraken service uses almost 500MB memory. When the service is just started, the memory usage was below 100MB.

The map is not blank also, all Peer struct are not released. But I'm not sure if the memory leak is caused by this.

{
   "data":{
      "updated_at":"2022-11-26T04:02:16.544191438Z",
      "active_peers":6,
      "closed_peers":2486,
      "active_rooms":4,
      "closed_rooms":119
   },
   "id":"1d870674-9329-44f7-b218-e40db615f52c"
}

image

Thanks, will check and fix it

@maggch97
Copy link
Author

I used the change in this PR #33. The service uses only 40MB memory after running for more than 12 hours. Above screenshot is also captured after the service running about 12 hours.

This change solves the biggest memory leak problems.

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