Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.

Fix memory leak in JavaScript Client - #13

Merged
j1elo merged 1 commit into
Kurento:masterfrom
naevatec:master
Sep 9, 2022
Merged

j1elo merged 1 commit into
Kurento:masterfrom
naevatec:master

Conversation

@slabajo

@slabajo slabajo commented Jul 21, 2022 •

Copy link
Copy Markdown
Member

What is the current behavior you want to change?

Kurento node client keeps a cache of instantiated Kurento elements in an 'objects' variable. That registry of instatiated objects should be maintained along with kurento object creation and release. However the release procedure has two problems:

  • Before emitting the 'release' event that in turn causes the kurento element to be deleted from the cache, the 'release' listener is removed, so that when the 'release' event is emitted no listener can process it and thus the object is not deleted from cache, causing a memory leak in node process.
  • There is also a problem with children elements from a pipeline. Kurento API allows to release an entire pipeline including its children just by releasing the pipeline, and indeed the server does accordingly. However on node client, pipeline does not track its children, so that when the pipeline is released (without previously releasing its children), children objects remain in the cache causing a memory leak in node process,

What is the new behavior provided by this change?

This PR, fixes two issues:

  • First one by not removing the release listener, so that it can correctly remove the object from cache
  • Second one by adding to the cache deletion function the feature to check all cached objects, and if any of its id begins with the id of the pipeline being deleted, it also emits the release event so that is also deleted form cache.

How has this been tested?

On a Kurento tutorial, specifically Hello World node tutorial, we get a heap dump before change, where we can observe that no Kurento element is removed from cache, and thus all Kurento objects are retained by that cache. Once the change is applied, we execute the same procedure and see that heapdump shows no instances in cache, nor objects in hepadump

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature / enhancement (non-breaking change which improves the project)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • My change requires a change to the documentation
  • My change requires a change in other repository

Checklist

  • I have read the Contribution Guidelines
  • I have added an explanation of what the changes do and why they should be included
  • I have written new tests for the changes, as applicable, and have successfully run them locally

@j1elo
j1elo merged commit b0b14fe into Kurento:master Sep 9, 2022
@j1elo j1elo changed the title bugfix memory leak Fix memory leak in JavaScript Client Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants