>I have this loop that runs ~22,000 iterations.  It brings the server to its
>knees.  The RAM usage skyrockets above 800 Megs cutting into major virtual
>memory.  But when I just write the output instead of storing it to a
>variable, it runs fine.  I'm trying to retrieve a list of email addresses
>and then write them to a file.
>
>     <cfscript>
>     emails = "";
>     for( i = 1; i lte list.recordcount; i=i+1 )
>       {
>       emails = emails & list.email[i] & chr(13) & chr(10);
>       }
>     </cfscript>
>
>I can't imagine that the list in memory would take that much room.  Does
>anyone have a suggestion?

It seems like it would make sense that WriteOutput takes less memory than 
storing to a variables. If you think about it, once it does the 
WriteOutput(), CF no longer needs to keep track of what's inside it -- it's 
no longer in memory. But if you store it to a variable, CF needs to go find 
that variable and then append to it and then store it again. That overhead 
is minimal with a smaller number of iterations. But 22,000 times is a lot of 
times!!

Are you sure that your approach is the best solution? I obviously have no 
idea what your ultimate goal is, but it looks from your code like you're 
trying to build a list of email address from a database with Windows 
carriage returns. Have you tried maybe using an array instead? Perhaps they 
have better performance than what you're doing? Or you could use ValueList() 
on the query column using a delimiter of "#Chr(13)##Chr(10)#".

Those are just off the top of my head, but 22,000 of anything is going to 
take a lot of processing time, so I wouldn't be so suprised to see what 
you're seeing.

Regards,
Dave.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to