RE: Re[4]: [xep-support] XEP Genarating pdfs take long time with .Net interface.

From: Krishnan, Navaneetha (nkrishnan@matlensilver.com)
Date: Tue May 25 2004 - 07:03:21 PDT

  • Next message: Victor Mote: "RE: Vedr.: Re: [xep-support] retrieve-marker question?"

    Hi,

    My original code was with out streaming. I was trying different options.

    I replaced
      GetXML = Stream_StringToBinary(objdoc.xml,"")
    with
      GetXML = objdoc.xml

    It runs fine for 5 minutes. It starts the problem around 10 minutes it
    will slow down a bit and in couple of minutes after that it stops. I
    I tried it on different machine too with windows 2000. On that it ran
    for 11 minutes or so and then crashed.

    Thanks

    Nav

    -----Original Message-----
    From: Alexander Peshkov [mailto:peshkov@renderx.com]
    Sent: Tuesday, May 25, 2004 4:43 AM
    To: Krishnan, Navaneetha
    Cc: support@renderx.com
    Subject: Re[4]: [xep-support] XEP Genarating pdfs take long time with
    .Net interface.

    Hello Nav,

    We examined your code and reproduced the error. The problem was in
    your function Stream_StringToBinary(). At the first glance we can see
    unclosed stream there that could be a reason of memory leak. Anyway, I
    don't quite understand why you have used this function at all - it
    wasn't necessary, everything works fine without it.
    We replaced
      GetXML = Stream_StringToBinary(objdoc.xml,"")
    with
      GetXML = objdoc.xml

    and after this modification the code run smooth under the stress test.
    Five minute run with WAS produced neither errors nor slowdown (every
    request was serviced in about two seconds).

    As for the XEP.NET performance - 10 minutes for a 45KB PDF is really
    strange. Actually it's orders of magnitude longer than expected. We
    have run a lot of tests with .Net and some of our clients use it
    already - XEP.Net is slower then XEP Java, but their performance is
    comparable. Therefore I believe that in this case the source of
    slowdown lies in your code or environment.

    Best regards,
    Alexander Peshkov mailto:peshkov@renderx.com
    RenderX

      
    KN> Hi, Thanks a lot for you help. I appreciate it.

    KN> I am trying XEP - XSL Formatting Engine for Paged Media Developer
    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-" &
    formatdatetime(dt,1) & "-" & Replace(formatdatetime(dt,3), ":", "-") &
    ".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='" &
    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
    45KB size. That is why I am trying the asp com arapper way. If you think
    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
    512MB ram.

    KN> It generates aroung 75 pdfs and after that I am getting "Error
    Encountered in COM surrogate process." Windows Errors.
    KN> Encountered unexpected error in dllhost. Cannot read memory at
    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
    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?
    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
    mailto:peshkov@renderx.com
    KN> RenderX

    KN>> Hi Alexander,

    KN>> Thanks for your reply. I suspected that this could be a problem
    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
    minutes. Initially it creates pdf for every three scond after 3 minutes
    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
    appreciated.

    KN>> CODE : I did not include the code for function
    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-" &
    formatdatetime(dt,1) & "-" & Replace(formatdatetime(dt,3), ":", "-") &
    ".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
    .Net
    KN>> interface.

    KN>> Hello Nav,

    KN>> As Nikolai has admitted in his recent post:
    http://xep.xattic.com/lists/xep-support/2045.html
    KN>> performance of XEP.Net is lower than of its Java counterpart,
    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
    in
    KN>> this respect) thus I suppose that the source of the problem may be
    in
    KN>> your code or it maybe a case of .Net-COM inter-operability issue.
    It
    KN>> definitely looks like XEP COM wrapper instances are not released by
    .Net.

    KN>> Best regards,
    KN>> Alexander Peshkov
    mailto:peshkov@renderx.com
    KN>> RenderX

    KN>>> Hi ,

    KN>>> Generating PDF with the .Net library takes a long time compared to
    the Java version.

    KN>>> If we use the COM library provided by XEP it is faster than the
    .Net version. But on a server it gets slower and slower and fails after
    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
    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

    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

    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

    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

    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

    -------------------
    (*) 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 : Tue May 25 2004 - 07:13:52 PDT