Discussion:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
(too old to reply)
PopCard
2011-01-25 21:13:02 UTC
Permalink
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
Stefan Wibmer
2011-02-17 13:16:03 UTC
Permalink
Hi PopCard

I have a similar problem and i found the problem.

I use a software called ISpy it is a CCTV Surveillance Motion detection SW and every time when motion is triggered it generates a WMV encoded file.

After a couple of weeks no files are generated anymore.
I could not find the problem and reinstall windows.

All was working again.

After a couple of weeks same problem (now)

I could not find a solution but i search hours why this could happen.

I found this:
Every time if a encoding starts windows is writing a WMV temp file located here
C:\Users\User\AppData\Local\Temp
Files looks like this
wmv366E.tmp
wmv6575.tmp

that files are 0kb or 1kb and will not be delete after encoding finished.

you can see the 4 letters after wmv thats 4 HEX digits if all compilations are full nothing will work anymore.

so deleting that files and all is working again.

so your solution is do make a script that automatically delete that bad files and all should work perfect
Post by PopCard
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 have 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)
"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)"
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
Submitted via EggHeadCafe
ASP.NET Drawing a chart using OWC11 - Office Web Components
http://www.eggheadcafe.com/tutorials/aspnet/601e9bc2-40ed-405e-b1b0-f416046b6698/aspnet-drawing-a-chart-using-owc11--office-web-components.aspx
Loading...