From: Alexander Peshkov (peshkov@renderx.com)
Date: Fri May 28 2004 - 04:41:00 PDT
Hello Nav,
After thorough investigation we have found a well-hidden memory leak
at JNI layer that reveals itself only when COM object re-created
numerous times in the same process. Updated version of COM wrapper
will be available shortly at http://xep.xattic.com. Thanks for your
feedback.
A few remarks regarding your ASP code: it is safer to load XML into
DOMDocument in synchronous mode so it makes sense to add something as
objDoc.async = false
before calling load() method; it is also recommended to close streams
and assign 'Nothing' to all objects at the end of method call.
You have mentioned that .NET version of XEP demonstrated extremely low
performance - we would like to see your code in case there is
something we can do about this problem.
Best regards,
Alexander Peshkov mailto:peshkov@renderx.com
RenderX
KN> Hi,
KN> My original code was with out streaming. I was trying different options.
KN> I replaced
KN> GetXML = Stream_StringToBinary(objdoc.xml,"")
KN> with
KN> GetXML = objdoc.xml
KN> It runs fine for 5 minutes. It starts the problem around 10 minutes it
KN> will slow down a bit and in couple of minutes after that it stops. I
KN> I tried it on different machine too with windows 2000. On that it ran
KN> for 11 minutes or so and then crashed.
KN> Thanks
KN> Nav
KN> -----Original Message-----
KN> From: Alexander Peshkov [mailto:peshkov@renderx.com]
KN> Sent: Tuesday, May 25, 2004 4:43 AM
KN> To: Krishnan, Navaneetha
KN> Cc: support@renderx.com
KN> Subject: Re[4]: [xep-support] XEP Genarating pdfs take long time with
KN> .Net interface.
KN> Hello Nav,
KN> We examined your code and reproduced the error. The problem was in
KN> your function Stream_StringToBinary(). At the first glance we can see
KN> unclosed stream there that could be a reason of memory leak. Anyway, I
KN> don't quite understand why you have used this function at all - it
KN> wasn't necessary, everything works fine without it.
KN> We replaced
KN> GetXML = Stream_StringToBinary(objdoc.xml,"")
KN> with
KN> GetXML = objdoc.xml
KN> and after this modification the code run smooth under the stress test.
KN> Five minute run with WAS produced neither errors nor slowdown (every
KN> request was serviced in about two seconds).
KN> As for the XEP.NET performance - 10 minutes for a 45KB PDF is really
KN> strange. Actually it's orders of magnitude longer than expected. We
KN> have run a lot of tests with .Net and some of our clients use it
KN> already - XEP.Net is slower then XEP Java, but their performance is
KN> comparable. Therefore I believe that in this case the source of
KN> slowdown lies in your code or environment.
KN> Best regards,
KN> Alexander Peshkov mailto:peshkov@renderx.com
KN> RenderX
KN>> Hi, Thanks a lot for you help. I appreciate it.
KN>> I am trying XEP - XSL Formatting Engine for Paged Media Developer
KN> Stamped Edition Version 3.7.4
KN>> COM Wrapper 1.5.
KN>> This is the complete source code for the asp file.
KN>> <%
KN>> Dim XEP
KN>> Set xep = server.CreateObject("XEP.XEPFormatter")
KN>> xep.setOutputFormat ("PDF")
KN>> XEP.SetStyleSheetFile Server.MapPath("AssetReportSVG.xsl")
KN>> dt = now()
KN>> objRet = XEP.Transform(GetXML())
KN>> strFileName = Server.MapPath(".") & "\MLReport-" &
KN> formatdatetime(dt,1) & "-" & Replace(formatdatetime(dt,3), ":", "-") &
KN> ".pdf"
KN>> SaveBinaryDataTextStream strFileName,objRet
KN>> Response.write "Created PDF File : " & strFileName
KN>> set xep = nothing
KN>> function GetXML()
KN>> dim objDOC
KN>> dim obj
KN>> set objDOC = server.CreateObject("MSXML2.DOMDocument")
KN>> objDoc.load Server.MapPath("AYA_input.xml")
KN>> attachimage objdoc,"Image1",Server.MapPath("BB1-A.SVG")
KN>> GetXML = Stream_StringToBinary(objdoc.xml,"")
KN>> end function
KN>> Private Sub AttachImage(Doc, ImageName, ImagePath )
KN>> Dim objDom
KN>> Dim objEl
KN>> Dim objParEl
KN>> Set objParEl = Doc.selectSingleNode("Images")
KN>> If objParEl Is Nothing Then
KN>> Set objParEl = Doc.createElement("Images")
KN>> Doc.documentElement.appendChild objParEl
KN>> End If
KN>> Set objEl = Doc.selectSingleNode("Images/Image[@Name='" &
KN> ImageName & "']")
KN>> If Not objEl Is Nothing Then
KN>> Doc.documentElement.removeChild objEl
KN>> End If
KN>> Set objEl = Doc.createElement("Image")
KN>> objEl.setAttribute "Name", ImageName
KN>> Set objDoc = Server.CreateObject("MSXML2.DOMDocument")
KN>> objDoc.Load ImagePath
KN>> objEl.appendChild objDoc.documentElement
KN>> objParEl.appendChild objEl
KN>> Set objDoc = Nothing
KN>> End Sub
KN>> Function Stream_StringToBinary(Text, CharSet)
KN>> Const adTypeText = 2
KN>> Const adTypeBinary = 1
KN>> 'Create Stream object
KN>> Dim BinaryStream 'As New Stream
KN>> Set BinaryStream = CreateObject("ADODB.Stream")
KN>> 'Specify stream type - we want To save text/string data.
KN>> BinaryStream.Type = adTypeText
KN>> 'Specify charset For the source text (unicode) data.
KN>> If Len(CharSet) > 0 Then
KN>> BinaryStream.CharSet = CharSet
KN>> Else
KN>> BinaryStream.CharSet = "us-ascii"
KN>> End If
KN>> 'Open the stream And write text/string data To the object
KN>> BinaryStream.Open
KN>> BinaryStream.WriteText Text
KN>> 'Change stream type To binary
KN>> BinaryStream.Position = 0
KN>> BinaryStream.Type = adTypeBinary
KN>> 'Ignore first two bytes - sign of
KN>> BinaryStream.Position = 0
KN>> 'Open the stream And get binary data from the object
KN>> Stream_StringToBinary = BinaryStream.Read
KN>> set BinaryStream = nothing
KN>> End Function
KN>> Function SaveBinaryDataTextStream(FileName, ByteArray)
KN>> 'Create FileSystemObject object
KN>> Dim FS: Set FS = CreateObject("Scripting.FileSystemObject")
KN>> 'Create text stream object
KN>> Dim TextStream
KN>> Set TextStream = FS.CreateTextFile(FileName)
KN>> 'Convert binary data To text And write them To the file
KN>> TextStream.Write BinaryToString(ByteArray)
KN>> TextStream.close
KN>> set TextStream = nothing
KN>> Set FS = nothing
KN>> End Function
KN>> Function BinaryToString(Binary)
KN>> Dim cl1, cl2, cl3, pl1, pl2, pl3
KN>> Dim L
KN>> cl1 = 1
KN>> cl2 = 1
KN>> cl3 = 1
KN>> L = LenB(Binary)
KN>> Do While cl1<=L
KN>> pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
KN>> cl1 = cl1 + 1
KN>> cl3 = cl3 + 1
KN>> If cl3>300 Then
KN>> pl2 = pl2 & pl3
KN>> pl3 = ""
KN>> cl3 = 1
KN>> cl2 = cl2 + 1
KN>> If cl2>200 Then
KN>> pl1 = pl1 & pl2
KN>> pl2 = ""
KN>> cl2 = 1
KN>> End If
KN>> End If
KN>> Loop
KN>> BinaryToString = pl1 & pl2 & pl3
KN>> End Function
%>>>
KN>> The .Net version takes around 10 minutes to genearte a pdf of around
KN> 45KB size. That is why I am trying the asp com arapper way. If you think
KN> that I can improve the perfomance with the .Net
KN>> version, I will go with that.
KN>> Details of error.
KN>> I am running this test on Windows XP professional. Pentium IV with
KN> 512MB ram.
KN>> It generates aroung 75 pdfs and after that I am getting "Error
KN> Encountered in COM surrogate process." Windows Errors.
KN>> Encountered unexpected error in dllhost. Cannot read memory at
KN> location XXXXX.
KN>> Thanks for you help.
KN>> Nav
KN>> -----Original Message-----
KN>> From: Alexander Peshkov [mailto:peshkov@renderx.com]
KN>> Sent: Monday, May 24, 2004 3:34 AM
KN>> To: Krishnan, Navaneetha
KN>> Cc: support@renderx.com
KN>> Subject: Re[2]: [xep-support] XEP Genarating pdfs take long time
KN> with
KN>> .Net interface.
KN>> Hello Nav,
KN>> I'm not an expert in ASP, but I knew that some of our clients
KN>> successfully use COM wrapper in their ASP projects for a long time.
KN>> Your problem still looks like a memory leak for me. Could it be that
KN>> your function SaveBinaryDataTextStream do not free some resources?
KN> Are
KN>> you using ASP.NET and latest version of XEP COM wrapper (1.5)?
KN>> Could you post complete code of your example?
KN>> Best regards,
KN>> Alexander Peshkov
KN> mailto:peshkov@renderx.com
KN>> RenderX
KN>>> Hi Alexander,
KN>>> Thanks for your reply. I suspected that this could be a problem
KN> with .Net.
KN>>> So creted a simple asp page which creates pdf from xml and xsl.
KN>>> When i tried to run it with WAS to load test it fails after few
KN> minutes. Initially it creates pdf for every three scond after 3 minutes
KN> it takes 15-20 secs and after a minute it throws the error.
KN>>> I have the code and the error message too. Any help will be
KN> appreciated.
KN>>> CODE : I did not include the code for function
KN> SaveBinaryDataTextStream
KN>>> Dim XEP
KN>>> Set xep = CreateObject("XEP.XEPFormatter")
KN>>> xep.setOutputFormat ("PDF")
KN>>> XEP.SetStyleSheetFile Server.MapPath("AssetReport.xsl")
KN>>> dt = now()
KN>>> objRet = XEP.TransformFile(Server.MapPath("AYA_input.xml"))
KN>>> strFileName = Server.MapPath(".") & "\MLReport-" &
KN> formatdatetime(dt,1) & "-" & Replace(formatdatetime(dt,3), ":", "-") &
KN> ".pdf"
KN>>> SaveBinaryDataTextStream strFileName,objRet
KN>>> Response.write "Created PDF File : " & strFileName
KN>>> set xep = nothing
KN>>> ERROR:
KN>>> Error Type:
KN>>> method setStylesheetFile() in XEP.IXEPFormatter (0x80004005)
KN>>> Can't set stylesheet
KN>>> /xslfopetest/createXEPpdf.asp, line 5
KN>>> Thanks
KN>>> Nav
KN>>> -----Original Message-----
KN>>> From: Alexander Peshkov [mailto:peshkov@renderx.com]
KN>>> Sent: Friday, May 21, 2004 4:33 AM
KN>>> To: Krishnan, Navaneetha
KN>>> Subject: Re: [xep-support] XEP Genarating pdfs take long time with
KN> .Net
KN>>> interface.
KN>>> Hello Nav,
KN>>> As Nikolai has admitted in his recent post:
KN> http://xep.xattic.com/lists/xep-support/2045.html
KN>>> performance of XEP.Net is lower than of its Java counterpart,
KN> because
KN>>> of .Net version is a port of Java one it's efficiency is lower.
KN>>> As for the problems with COM wrapper - judging on the symptoms you
KN>>> describe it's a typical memory leak. We believe that our COM
KN>>> wrapper does not have such leaks itself (it was thoroughly tested
KN> in
KN>>> this respect) thus I suppose that the source of the problem may be
KN> in
KN>>> your code or it maybe a case of .Net-COM inter-operability issue.
KN> It
KN>>> definitely looks like XEP COM wrapper instances are not released by
KN> .Net.
KN>>> Best regards,
KN>>> Alexander Peshkov
KN> mailto:peshkov@renderx.com
KN>>> RenderX
KN>>>> Hi ,
KN>>>> Generating PDF with the .Net library takes a long time compared to
KN> the Java version.
KN>>>> If we use the COM library provided by XEP it is faster than the
KN> .Net version. But on a server it gets slower and slower and fails after
KN> a while saying cannot set stylesheet.
KN>>>> Any alternate or workaround to this problem.
KN>>>> Thanks in advance
KN>>>> -Nav
KN>>>> -------------------
KN>>>> (*) To unsubscribe, send a message with words 'unsubscribe
KN> xep-support'
KN>>>> in the body of the message to majordomo@renderx.com from the
KN> address
KN>>>> you are subscribed from.
KN>>>> (*) By using the Service, you expressly agree to these Terms of
KN> Service http://www.renderx.com/tos.html
KN>>> -------------------
KN>>> (*) To unsubscribe, send a message with words 'unsubscribe
KN> xep-support'
KN>>> in the body of the message to majordomo@renderx.com from the
KN> address
KN>>> you are subscribed from.
KN>>> (*) By using the Service, you expressly agree to these Terms of
KN> Service http://www.renderx.com/tos.html
KN>>> -------------------
KN>>> (*) To unsubscribe, send a message with words 'unsubscribe
KN> xep-support'
KN>>> in the body of the message to majordomo@renderx.com from the
KN> address
KN>>> you are subscribed from.
KN>>> (*) By using the Service, you expressly agree to these Terms of
KN> Service http://www.renderx.com/tos.html
KN>> -------------------
KN>> (*) To unsubscribe, send a message with words 'unsubscribe
KN> xep-support'
KN>> in the body of the message to majordomo@renderx.com from the address
KN>> you are subscribed from.
KN>> (*) By using the Service, you expressly agree to these Terms of
KN> Service http://www.renderx.com/tos.html
KN>> -------------------
KN>> (*) To unsubscribe, send a message with words 'unsubscribe
KN> xep-support'
KN>> in the body of the message to majordomo@renderx.com from the address
KN>> you are subscribed from.
KN>> (*) By using the Service, you expressly agree to these Terms of
KN> Service http://www.renderx.com/tos.html
KN> -------------------
KN> (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
KN> in the body of the message to majordomo@renderx.com from the address
KN> you are subscribed from.
KN> (*) By using the Service, you expressly agree to these Terms of Service
KN> http://www.renderx.com/tos.html
KN> -------------------
KN> (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
KN> in the body of the message to majordomo@renderx.com from the address
KN> you are subscribed from.
KN> (*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html
-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo@renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html
This archive was generated by hypermail 2.1.5 : Fri May 28 2004 - 04:53:12 PDT