twitter

Recent Comments

David Boyer
David Boyer January 13, 2012 at 10:05AM
Is Your CFLOOP Hogging Memory or Causing OutOfMemory Errors?

Interesting to find that out, wouldn't have expected it to be a problem. I've had similar...

baljit dhanoa
baljit dhanoa January 12, 2012 at 9:08AM
Creating A Recent Comments Widget With Disqus's API and PHP

Creating A Recent Comments Widget With Disqus's API and PHP good code pls try

Web Hosting Provider
Web Hosting Provider January 10, 2012 at 5:23PM
Creating A Recent Comments Widget With Disqus's API and PHP

Superb and very informative for me,,,

web hosting
web hosting December 2, 2011 at 7:28AM
If PHP's file_get_contents Function is Failing With IIS 7

I am new guy for this PHP. i get it clear idea about your topic.All the points are explained...

Aaron J. White
Aaron J. White November 14, 2011 at 11:54PM
Creating A Recent Comments Widget With Disqus's API and PHP

If you want to put the number of posts in a different area than the recent comments section...

Aaron J. White
Aaron J. White November 14, 2011 at 10:10PM
Creating A Recent Comments Widget With Disqus's API and PHP

It depends, are you using wordpress or joomla? I have a different plugin that checks disqus for...

Yulia Novozhilova
Yulia Novozhilova November 14, 2011 at 4:22PM
Creating A Recent Comments Widget With Disqus's API and PHP

very cool... it works! Do you know if it is possible to include number of total post likes on...

Aaron J. White
Aaron J. White October 30, 2011 at 10:40AM
Creating A Recent Comments Widget With Disqus's API and PHP

Hmm...It would probably help if I post a comment on my site so people can actually see my...

Is Your CFLOOP Hogging Memory or Causing OutOfMemory Errors?

Posted: January 13th, 2012 - So I have been working on a script in OpenBD that loops over a large 1.2GB xml file and parses specific nodes. Since the file is so big I have to loop over the file line by line and build each node individually before running xmlparse() on the node. Everything was working just dandy until I got to around 6 million lines.

Looking at the task manager on the server I could see the memory gradually rising and eventually at around 7 million the script died. I had no clue what to do and tried several very unsuccesffuly modifications until an awesome person by the name of Jamie MacDonald on the OpenBD google group told me to try putting <cfflush /> at the end of my loop. The explanation given to me was that even though I was not outputting any data the whitespace characters inside the loop may be adding up because the CFML engine thinks it is needed to render a page and thus holds the whitespace in the buffer.

HUH!? Whitespace problems inside a component with output="false"? CFdocs.org says that output= false should make the code act like it is inside one big cfsilent, but maybe I am misunderstanding something. It could also be a bug specific to OpenBD, but maybe not. Anyway using cfflush allowed me to process the whole file with no memory problems. I watched the task manager while the script was running and with cfflush the memory stayed consitant at a normal level.  So to sum up, if you run into memory issues while using a long running cfloop try putting <cfflush /> at the very end of the loop. Hopefully this will be useful to people using the other CFML engines besides OpenBD too.


blog comments powered by Disqus