PopCard
2011-01-25 21:13:02 UTC
i have an application which makes multithreaded calls to the following
"StartEncoding" method. i am trying to encode about 200,000 files per
day. The following code works fine on my old server 2003 x86 machine.
I've moved the code to a server 2008 r2 x64 machine and i get the
following error after a random number of files. sometimes after 100
files, sometimes after 10,000 files. I have about 12 million files to
encode, so I need this to work! Please advise!!!!! (BTW, the code
below is encoding ~6 files per second with 10 threads, my old server
was maxed out around ~2 files per second. I know code below is really
really unoptimized, but for debugging thats where its at now)
Exception:
"System.AccessViolationException: Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.
at WMEncoderLib.WMEncoderClass.PrepareToEncode(Boolean bPrepare)"
Code Snippet:
Public Function StartEncoding(ByVal strInputFileName As String, ByVal
strOutputFileName As String, ByVal blnAsynchronous As Boolean) As
Boolean
Try
'WM9 Encoder
objWMEncoder = New WMEncoder()
'WM9 Profile
objPro = New WMEncProfile2()
'Get encoder source group collection
colSrcGrpColl = objWMEncoder.SourceGroupCollection
'Load Profile from file
objPro.LoadFromFile(strProfileFileName)
'Add our group to the collection
objSrcGrp = colSrcGrpColl.Add("WMAEncoder")
'Add our source type to the new group
objSrcAud =
objSrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO)
'Add Profile to Source Group
objSrcGrp.Profile = objPro
'Create Encoder file
objFile = CType(objWMEncoder.File, IWMEncFile2)
'Set input
objSrcAud.SetInput(strInputFileName)
'Set output
objFile.LocalFileName = strOutputFileName
'prepare encoder
objWMEncoder.PrepareToEncode(True)
'reset wait
waitHandle.Reset()
'Start encoding
objWMEncoder.Start()
'if its not an asynchronous request wait until complete
If Not blnAsynchronous Then
'wait for all events
waitHandle.WaitOne()
End If
Return True
Catch ex As Exception
Return False
Finally
objPro = Nothing
objWMEncoder = Nothing
waitHandle.Set()
End Try
End Function
"StartEncoding" method. i am trying to encode about 200,000 files per
day. The following code works fine on my old server 2003 x86 machine.
I've moved the code to a server 2008 r2 x64 machine and i get the
following error after a random number of files. sometimes after 100
files, sometimes after 10,000 files. I have about 12 million files to
encode, so I need this to work! Please advise!!!!! (BTW, the code
below is encoding ~6 files per second with 10 threads, my old server
was maxed out around ~2 files per second. I know code below is really
really unoptimized, but for debugging thats where its at now)
Exception:
"System.AccessViolationException: Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.
at WMEncoderLib.WMEncoderClass.PrepareToEncode(Boolean bPrepare)"
Code Snippet:
Public Function StartEncoding(ByVal strInputFileName As String, ByVal
strOutputFileName As String, ByVal blnAsynchronous As Boolean) As
Boolean
Try
'WM9 Encoder
objWMEncoder = New WMEncoder()
'WM9 Profile
objPro = New WMEncProfile2()
'Get encoder source group collection
colSrcGrpColl = objWMEncoder.SourceGroupCollection
'Load Profile from file
objPro.LoadFromFile(strProfileFileName)
'Add our group to the collection
objSrcGrp = colSrcGrpColl.Add("WMAEncoder")
'Add our source type to the new group
objSrcAud =
objSrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO)
'Add Profile to Source Group
objSrcGrp.Profile = objPro
'Create Encoder file
objFile = CType(objWMEncoder.File, IWMEncFile2)
'Set input
objSrcAud.SetInput(strInputFileName)
'Set output
objFile.LocalFileName = strOutputFileName
'prepare encoder
objWMEncoder.PrepareToEncode(True)
'reset wait
waitHandle.Reset()
'Start encoding
objWMEncoder.Start()
'if its not an asynchronous request wait until complete
If Not blnAsynchronous Then
'wait for all events
waitHandle.WaitOne()
End If
Return True
Catch ex As Exception
Return False
Finally
objPro = Nothing
objWMEncoder = Nothing
waitHandle.Set()
End Try
End Function