473,788 Members | 2,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WMEncoder leaves open system handles around after running

2 New Member
I am using the WMEncoder (seris 9) object inside a .net(c#) encoding app that encodes a wave file to a wma file. Everytime I create and use the WMEncoder object it leak system handles even after I try to release it via GC. If I let my app running continuously it will eventually crash because it runs out of system resources. My code sample is below. I am following the examples in the SDK.
Please help.

Thanks.
Russell Bonakdar

public void EncodeFile()
{
WMEncoder mEncoder = new WMEncoder();
mEncoder.Synchr onizeOperation = false; // false makes calling Start create a separate thread to cue and set up the device, and returns immediately.
mEncoder.OnStat eChange += new _IWMEncoderEven ts_OnStateChang eEventHandler(O nStateChange);
mEncoder.OnErro r += new _IWMEncoderEven ts_OnErrorEvent Handler(OnError );

// Create and add a source group to the source group collection
IWMEncSourceGro up mSrcGrp = mEncoder.Source GroupCollection .Add("MySourceG roup");
IWMEncAudioSour ce mSrcAud = (IWMEncAudioSou rce)mSrcGrp.Add Source(WMENC_SO URCE_TYPE.WMENC _AUDIO);

mSrcAud.SetInpu t(mFullPath, "", "");

// Set the two-pass encoding flag
mSrcAud.PreProc essPass = (short)(mDualPa ss ? 1 : 0);

// Set current output file name
mEncoder.File.L ocalFileName = String.Format(" {0}\\{1}_{2}.WM A", mOutFolderPath, mMasterID, index);
mCurOutputFile = mEncoder.File.L ocalFileName;

form.AddLogMess age(String.Form at("Encoding WMA: {0} to {1}", mFullPath, mEncoder.File.L ocalFileName));
mSrcGrp.set_Pro file(Pro2);

mEncoder.Prepar eToEncode(true) ;
mEncoder.Start( );

form.AddLogMess age(String.Form at("EncodeFile( {0}) is waiting for the encoder to Stop...", Thread.CurrentT hread.ManagedTh readId));
while (mEncoder.RunSt ate != WMENC_ENCODER_S TATE.WMENC_ENCO DER_STOPPED)
{ // Keep UI messages moving, so the form remains responsive
Application.DoE vents();
}

// try to cleanup after the encoder
mSrcGrp.RemoveS ource(WMENC_SOU RCE_TYPE.WMENC_ AUDIO, 0);
mSrcAud = null;
mEncoder.Source GroupCollection .Remove("MySour ceGroup");
mSrcGrp = null;
mEncoder = null;
Application.DoE vents();
System.GC.Colle ct();
System.Threadin g.Thread.Sleep( 0);
}
Oct 20 '06 #1
1 2883
xtomiii
1 New Member
// after this line
GC.Collect();
// you're missing this line
GC.WaitForPendi ngFinalizers();

// aslo I advide to remove video from source group
Jul 15 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1816
by: jnc | last post by:
I have quite a weird problem whereby I need to obtain the username of the person who has a file open and it need to work over the nework. To explain a bit more.....I have a file system watcher which is watching a file over the network. The file can be opened by multiple users from mutiple computers within the same domain. Currently the file system watcher object (sits on a server watching out on the network) will tell me when the file...
10
2347
by: Niall | last post by:
I'm not quite sure which groups to post this to, so short of a massive crosspost, I decided on these two. I am running into troubles with resource usage of our app on Win2k and above systems. In several places, I have seen it said that the WinNT model only limits resources to available memory. However, I have seen errors caused by running out of resources on a machine with over 1GB of free memory (running Win2k server), as well as on my...
0
267
by: Shamin | last post by:
Hi, Thanks in advance for answering to my Question. I'm stuck with this problem and would really appreciate any help. I have 2 aspx files (Main.aspx and ReportViewer.aspx). Main.aspx has a datagrid which is populated with list of report names. When the user click on the name of a report, I display a panel that has a button which on clicking will run the report. The report will open in ReportViewer.aspx, This page has a Report Document...
10
3684
by: One Handed Man [ OHM ] | last post by:
If this is duplicated, I'm sorry because I cant find the original post I made today Anyway . . Now its my turn to ask a question I want to develop an app which will run in the system tray. How can I do this?
2
5013
by: Sam | last post by:
Hi, I can't figure out how to detect when my mouse cursor leaves a panel control. It should not trigger the event (or do anything) when the mouse leave the panel but still is over a control that is contained by the panel. I've done this : Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs) If Cursor.Position.X > Me.Location.X + Me.Width Or Cursor.Position.Y > Me.Location.Y + Me.Height _
0
9097
by: Asif Mohammed | last post by:
Hello, I have a datagridview bound to a database table with 2 columns. One is an ID column "NameID" which is hidden, the other is called "Name". The schema picture is here : http://img89.imageshack.us/img89/1251/dbschemaep9.jpg What happens is : 1. Form loads with values from database inside the DGV 2. I press the checkbox to enable editing/adding etc in the grid (see code event)
0
1302
by: Asif Mohammed | last post by:
Hello, I have a datagridview bound to a database table with 2 columns. One is an ID column "NameID" which is hidden, the other is called "Name". The schema picture is here : http://img89.imageshack.us/img89/1251/dbschemaep9.jpg What happens is : 1. Form loads with values from database inside the DGV 2. I press the checkbox to enable editing/adding etc in the grid (see code event)
0
1479
by: PlayQ | last post by:
Hello, I am using the C# example code in the WMEncoder Series 9 SDK to encode a series of audio files but after a while I notice a handle leak in the system. The handle count keeps going up until it finally crashes the encoder and my application. Is there a known issue with using the C# interfaces of this SDK? If so what is the workaround? Please help as I am stuck. Thanks, Russell B.
10
6110
by: jimmy | last post by:
Hi again, sorry for posting two questions so close together but im working on a school project which is due in soon and running into some difficulties implementing the database parts. I have the code below which when executed generates the following error message: 'There is already an open datareader with this command which must be closed first' Private Sub MainMenu_Load(ByVal sender As System.Object, ByVal e As
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.