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

Fix memory leak in spawns #4820

Merged
merged 3 commits into from
Nov 1, 2024
Merged

Conversation

Codinablack
Copy link
Contributor

@Codinablack Codinablack commented Nov 1, 2024

When we spawn a monster, we increment the count on the monster object for the entry into the spawnedmap. When we remove the monster from the spawnedmap because of it being outside the zone, we don't decrement the ref count, which leads to a leak.

There is also extra logic in place for a spawn ID 0. Not sure why monsters were being removed from the spawned map and placed back into it with 0 as the id for when they leave the area, but I find no other interactions or checks for spawn id being 0, so there seems to be zero reason, and whatever was so special about spawn id 0 doesn't exist anymore, so I cleaned up that old code that has not been in use since apparently before TFS was TFS.

Pull Request Prelude

  • I have followed [proper The Forgotten Server code styling][code].
  • I have read and understood the [contribution guidelines][cont] before making this PR.
  • I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.

Changes Proposed

remove dead code

Issues addressed:

Memory leak
Overspawn

When we spawn a monster, we increment the count on the monster object for the entry into the spawnedmap. When we remove the monster from the spawnedmap because of it being outside the zone, we don't decrement the ref count, which leads to a leak.

There is also extra logic in place for a spawn ID 0. Not sure why monsters were being removed from the spawned map and placed back into it with 0 as the id for when they leave the area, but I find no other interactions or checks for spawn id being 0, so there seems to be zero reason, and whatever was so special about spawn id 0 doesn't exist anymore, so I cleaned up that old code that has not been in use since apparently before TFS was TFS.
@ghost ghost added the bugfix label Nov 1, 2024
@nekiro nekiro merged commit d7bd06b into otland:master Nov 1, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants