Riddle me this...

I use CF has pretty much a full on utility language for all needs.  My
particular need this time was to parse through an 11gb ASCII java heap
file to look for specific strings.  If I run this through a cfloop my
openbd heap will rise to 1gb within about 20 minutes and crash.  If I
run this with a while loop in cfscript my heap never gets over 30mb
and I can cruise through the file in about a hour.

Two examples on how I was doing this (with the obvious notion there
are probably others.)
Also note this little snippet doesn't "do" anything.  It is in its
most basic form with only reading the file in and looping through it
line by line:

using cfloop:

<cfset filename = "C:\hprof\in.hprof.txt">
<cfset logName = "C:\hprof\output.log">
<cfscript>
fileReader = createobject("java","java.io.FileReader");
fileReader.init(filename);
brReader = createObject("java","java.io.BufferedReader");
brReader.init(fileReader);
</cfscript>
<cffile action="write" file="#logName#" output="">
<cfset myVal = brReader.readLine()>
<cfloop condition="isDefined('myVal')">
        <cfset myVal = brReader.readLine()>
        <cfif NOT isDefined("myVal")>
                <cfbreak>
        <cfelse>
                <!--- do my work here --->
        </cfif>
</cfloop>
<cfscript>
brReader.close();
</cfscript>
NOTE: I've done various combos with the loop.  Specifying a start and
arbitrary end (to remove "condition" as being a possible culprit) but
it doesn't matter.

Using cfscript:
<cfscript>
 letterFile = createobject("java", "java.io.File").init("C:\hprof
\output.txt");
 letterStream = createobject("java",
"java.io.FileWriter").init(letterFile);
 printStream =
createobject("java","java.io.PrintWriter").init(letterStream);
srcFile = "C:\hprof\in.hprof.txt";

fr = createObject("java","java.io.FileReader");
 fr.init(srcFile);
 br = createObject("java","java.io.BufferedReader");
 br.init(fr);
 str = br.readLine();
 while (isDefined("str")) {
  // do my work here

  }
   str = br.readLine();
 }
 // close the buffered reader object
 br.close();
 writeOutput(cnt);
</cfscript>

Now I totally accept that I what I'm doing is anything but
mainstream.  Using java for this is clearly a much better way.  But
hey, I don't know how to code in java so I use what I know.  So I
thought I would report this as being something interesting.

Thanks,
Josh

--~--~---------~--~----~------------~-------~--~----~
Open BlueDragon Public Mailing List
 http://groups.google.com/group/openbd?hl=en
 official blog @ http://blog.openbluedragon.org/
!! save a network - trim replies before posting !!
-~----------~----~----~----~------~----~------~--~---

Reply via email to