Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

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

0
Brommers
Asked:
Brommers
2 Solutions
 
-dev-Commented:
Hi I tried your code out and didnt have any significant memory loss. The program stayed in the 38-50k range even after loading multiple avi's and total system memory reported the same. It might be the avi you are using for testing.
0
 
riaancorneliusCommented:
same here. No significant increase in memory usage.
0
 
BrommersAuthor Commented:
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
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now