Link to home
Start Free TrialLog in
Avatar of Brommers
Brommers

asked on

Need help desperately

Hi everyone,

I have an app that uses the Active Movie Library to display many AVI files (one at a time) and am getting HUGE memory leaks after each AVI is opened.

I need to know if its just my system as one friend tried my code and reported no great change in memory usage.

Please, it'll take you 5 mins to try this out. If you could report back to me here I'd be eternally grateful. I need to know if you get the leak too.

Reference to Active Movie Library, Common Dialog control from components, 1 Picture box, 2 command buttons.

--------------------

Private m_boolVideoRunning As Boolean       'Flag used to trigger clock
Private m_objBasicAudio  As IBasicAudio         'Basic Audio Object
Private m_objBasicVideo As IBasicVideo          'Basic Video Object
Private m_objMediaEvent As IMediaEvent        'MediaEvent Object
Private m_objVideoWindow As IVideoWindow   'VideoWindow Object
Private m_objMediaControl As IMediaControl    'MediaControl Object
Private m_objMediaPosition As IMediaPosition 'MediaPosition Object
Private Sub Command1_Click()
Dim m_bstrfilename As String
    CommonDialog1.Filter = "Open an AVI File (*.avi)|*.avi"
    CommonDialog1.ShowOpen
    m_bstrfilename = ""
    m_bstrfilename = CommonDialog1.FileName
    cleardxpreview
    Set m_objMediaControl = New FilgraphManager
    Call m_objMediaControl.RenderFile(m_bstrfilename)

    Set m_objBasicAudio = m_objMediaControl

    Set m_objVideoWindow = m_objMediaControl
    m_objVideoWindow.WindowStyle = CLng(&H6000000)
    m_objVideoWindow.Top = 0
    m_objVideoWindow.Left = 0
    m_objVideoWindow.Width = Picture1.Width
    m_objVideoWindow.Height = Picture1.Height
    m_objVideoWindow.Owner = Picture1.hWnd
    Set m_objMediaEvent = m_objMediaControl
    Set m_objMediaPosition = m_objMediaControl
    m_objMediaControl.Pause


End Sub
Private Sub cleardxpreview()
    If Not m_objMediaControl Is Nothing Then
        m_objMediaControl.Stop
    End If
    If Not m_objVideoWindow Is Nothing Then
        m_objVideoWindow.Left = Screen.Width * 8
        m_objVideoWindow.Top = Screen.Height * 8
        m_objVideoWindow.Owner = 0
    End If
 
    Set m_objBasicAudio = Nothing
    Set m_objBasicVideo = Nothing
    Set m_objMediaControl = Nothing
    Set m_objVideoWindow = Nothing
    Set m_objMediaPosition = Nothing
    Set m_objMediaPosition = Nothing

End Sub

Private Sub Command2_Click()
m_objMediaControl.Run
End Sub

Private Sub Form_Load()
Me.Show
End Sub

Private Sub Form_Unload(Cancel As Integer)
cleardxpreview
End Sub

ASKER CERTIFIED SOLUTION
Avatar of -dev-
-dev-
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Brommers
Brommers

ASKER

Thanks guys it looks like the problem was codec related since upon testing AVI's not compressed with the normal codec I used the problem seems to have disappeared