Ralf
Ralf

Reputation: 9573

DirectShow MP4Demux application out of memory on IMediaControl::Run

I'm using the Geraint Davies' MP4Demux to stream some previously encoded mp4 files.

In a past investigation I found that the MP4Demux allocates the memory for all the atoms on loading. For smaller files this works ok, but using a larger mp4 file (about 1.2GB) I get an out of memory error on IMediaControl::Run.

One option would be to rewrite/edit the mp4 demux to have a pool/circular buffer of memory and to only read the frames as they are needed/requested, but I'm wondering if there is a simpler solution e.g. like somehow increasing the memory that the DirectShow application can use (it is a 32-bit console application though).

Upvotes: 1

Views: 212

Answers (1)

Roman Ryltsov
Roman Ryltsov

Reputation: 69716

Typical memory consumers in graphs are memory allocators. Leaving the underlying reasons aside, sometimes allocation is excessive: too many buffers and/or too large buffers. The allocation is typically taking place in stopped-to-paused transition, which might be a part of Run call (it is actually a part of Pause call, but if you call Run while stopped, there is implicit Pause call as well).

Whatever is the reason, allocators are first thing to check: pause the graph and review process private bytes, process virtual address consumption, allocator properties (GraphStudioNext and DirectShowSpy should together be able to do this), and check if it makes sense or it is grabbing too much.

Sometimes it simply can take the process too close to virtual address space limit and the failure is not immediate, but memory pressure makes something else fail shortly afterwards.

Upvotes: 2

Related Questions