I have a such simple code:
// cache is disabled
[OutputCache(NoStore = true, Duration = 0)]
public async Task<ActionResult> GetVideo(string path)
{
byte[] data = await _fileService.GetFileAsync(path);
if (data == null)
return HttpNotFound();
return File(data, "video/mp4");
}
This code is very simple: it retrieves file's content as byte array and sends it to client. I have a web page that contains some video
tags. All of those tags use GetVideo
as source. Each video is about 400-500 Mb. After page is ready w3wp.exe in Task Manager takes 3-4 Gb RAM and doesn't release memory. As I wrote previously I disable resutl caching with OutputCacheAttribute.
The problem doesn't hide in method GetFileAsync
because when I replace line
byte[] data = await _fileService.GetFileAsync(path);
with line
byte[] data = System.IO.File.ReadAllBytes(Server.MapPath(path));
this problem still exists. Maybe anyone knows how to release memory after sending bytes to client?