How is this timeout on CFLOOP possible?

I've been having troubles with a particular hosting provider for a client's site, and rather than going on a rampage about my troubles with the provider, let me get to the really odd error that I get on the hosted site intermittently, but cannot duplicate on my development box.

Here is the offending code:

<cfdirectory name="Dir" filter="*.jpg" directory="/my/path/to/photos/">
<cfloop index="i" from="1" to="#Dir.RecordCount#"><cfset numArray[i]=i></cfloop>
<cfset QueryAddColumn(Dir,"Num",numArray)>

Sometimes this will process in a second and move on, other times the page will sit there for 30 seconds, time out, and then report, "The request has exceeded the allowable time limit Tag: CFLOOP".

Never mind even why I may be doing this or if there is a better way.. I'd like to know how this is even feasible. I know <cfloop> is obviously a candidate for infinite loops, but I'm looping over files in a directory that won't number more than a few hundred. Heck, even if for some crazy reason the record count provides a number in the millions, I'm executing such a simple command that it should take a couple seconds at most.

I don't understand how this error is feasibly possible without there being serious issues with the ColdFusion service on the server, which I actually wouldn't doubt.

  Theme Brought to you by Directory Journal and Elegant Directory.