Out of Memory Exception

Mar 27, 2013 at 9:02 PM
Hi,

I am using MediaUriElement for playing a specific media file (Size is about 300 M, mov format), and I have installed KLite Codec 9.8 Standard for the the native player to support the mov files.

But the application starts with a low amount of memory consumption and as it plays for a while the memory consumption goes up exponentially and it crashes.

But when I use the native MediaElement the memory consumption is stable.

I am using the below code
MediaUriElement player = new MediaUriElement();
        player.BeginInit();
        player.LoadedBehavior = WPFMediaKit.DirectShow.MediaPlayers.MediaState.Manual;
        player.Source = new Uri(@"D:\1.mov"); 
        player.Volume = 10;
        player.Width = 100;
        player.Height = 100;
        player.VideoRenderer = VideoRendererType.VideoMixingRenderer9;
        player.Stretch = Stretch.UniformToFill;
        player.MediaFailed += new EventHandler<MediaFailedEventArgs>(player_MediaFailed);
        player.MediaOpened += new RoutedEventHandler(player_MediaOpened);
        player.MediaEnded += new RoutedEventHandler(player_MediaEnded);
        player.MediaClosed += new RoutedEventHandler(player_MediaClosed);
        player.EndInit();
        g.Children.Add(player); // Add the control to the grid
        player.Play(); 
Apr 2, 2013 at 5:53 PM
Hi,

I have similar experience, I use wpfmediakit to play video streams from RTMP packets. When displaying starts memory usage starts growing too but not exponentialy, just lineary. After a long while app crashes with outofmemory exception or similar (at about 500M of memory in task manager). My case is a bit more complicated cause I developed my own push source filter to feed the graph and as I can debug, after delivering the mediasample downstream, the memory allocation in media sample might not released.
I do this in a background thread in the source filter:
HRESULT hr=S_OK;
while(1)
{
    IMediaSample* pSample;
    hr=pin->m_callBackInstance->OnStop();
    if(hr==-2)
        return;
    hr=pin->GetDeliveryBuffer(&pSample,NULL,NULL,0);
    if(FAILED(hr))
        continue;
    hr=pin->m_callBackInstance->OnDeliverSample(pSample); //Marshal.copy the frame data here in C#
    if(hr==-2)
    {
        return;
    }
    if(FAILED(hr))
        continue;
    hr=pin->Deliver(pSample);
    hr=pSample->Release();
}
However I have no clue what could be the problem.
If anybody has idea, please share....
Apr 6, 2013 at 3:17 PM
Hi again,

It seems I was successful in solving this problem, I write here might be helpful for others avoiding many hours of debugging.
After a lots of helpless investigation I realized a very simple issue: Im using klite code pack though ffdshow is not the default decoder for FLV types (h263,AVC). I enabled ffdshow decoding these types and voila, memory leakage disappeared!