Skip to content

HoloLens 2 - Encoder stops after 90 frames + possible memory leak? #101

@dgblack

Description

@dgblack

Hi, thanks for the great library! I'm having a bit of an odd issue on a HoloLens 2 (Unity, UWP, ARM, latest release of PopH264). I'm pushing frames whenever one becomes available from the camera, and every time I push a frame, I increment a frameCounter. In Unity's Update function, I call:

var FrameMaybe = Encoder.PopFrame();
if (FrameMaybe is PopH264.H264Frame Frame)
{
    Debug.Log($"Success. Frame counter {frameCounter}");
    await Task.Run(() => { callback(Frame.H264Data); });
}
else
    Debug.Log($"Failed. Frame counter {frameCounter}");
FrameMaybe = null;

It consistently gets up to frameCounter = 90 with success on every frame, and then fails for the rest of the execution.

I can circumvent the issue by having two encoders, and every time the count almost reaches 90, I switch to the other one and dispose of the first, then switch back and dispose of the second, etc. This seems inefficient and unnecessary though. Any idea how to fix the actual problem?

Additionally, I monitored the memory usage while running this, and it creeps up pretty quickly. As soon as I stop encoding the frames, it stops increasing. Is it possible that there's a memory leak in the encoder somewhere? I'm not using Texture2Ds or anything that would cause the memory increase on the Unity side.

Edit: I kept all the code but commented out the push, and the memory leak disappeared, so nothing before the encoder is causing the leak. I then kept everything but after popping didn't do anything with the frame, and the memory leak persisted, so nothing after the encoder is causing the leak either. Really seems like it's inside the PopH264 library.

Thank you!
David

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions