Memory issue in ASP.NET Core video playback endpoint
I'm trying to implement a very basic endpoint which responds with file to angular front-end but when video is fetched its all good even when video is playing normally and even when I seek the video forward but the second I seek the video backwards and continuously seek it back and forth the ram usage increases by MBs the more I seek and since the time I seek the video back the ram usage keeps rising in 1 MBs or so every few seconds even as video is playing normally which didn't happen until i seek the video back.
I'm talking about a 450 MB 3-4 mins video.
The ram usage never goes down either, why's this happening, should I be concerned or will GC do its thing eventually or as memory rises more?
4 Replies
Maybe a filestream object will manage resources better than the buffering.
https://learn.microsoft.com/en-us/dotnet/api/system.io.filestream?view=net-9.0
FileStream Class (System.IO)
Provides a Stream for a file, supporting both synchronous and asynchronous read and write operations.
It would not.
In fact it would likely make it worse.
well I've tried this and it didn't really help, identical memory rising behaviour as in the above code
I also tried returning new FileStreamResult but same thing
I also tried returning this by creating new class & implementing IActionResult with method below but literally got identical memory rising behavior as I described in the post:
also I noticed for some reason the bytes requested in Range header implied it requested for full video at once, the value of Range header was often like "bytes=73007104-"
Well that's the client's fault