Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2006
    Thanked 0 Times in 0 Posts

    Out of memory errors (update)

    I am trying to create a search script but I am running into an out of memory error. Here is the search subroutine which loops multiple times:

    sub SubSearch()
     path = folderarray(arraycounter)	'set path to current folder to search
     if arraycounter > 0 then
      temp = arraycounter - 1
      folderarray(temp) = 0
     end if
    ' Set fso = server.CreateObject("Scripting.FileSystemObject")
     set fo = fso.getfolder(path)
    ' response.write(fo & "<br>")
     for each subfolder in fo.subfolders
      temppath = subfolder
      redim preserve folderarray(counter)
      folderarray(counter) = temppath
      counter = counter + 1
     for each file in fo.files
      if fso.getextensionname(file) = "mht" then
       set readfile=fso.opentextfile(file,1,false)
       set readfilename=fso.getfile(file)
       if file.size > 0 then	'if something in the file, read it MAY NEED TO CHANGE
        exit for
       end if
       urlfilename = replace(mid(readfilename, 29),"\","/")
       urlfilename = replace(urlfilename," ","%20")
       'Necessary to keep it from searching through the picture garbage text
       find_html = instr(file, "</html>")
       file = left(file, find_html)
       'The actual search part
       isinfile = instr(1, file, search, 1)
       if isinfile > 0 then
        'Pulls the page title out
        title_str = instr(file, "<title>")
        title_str = title_str + 7     'adds 7 to start right after <title>
        title_end = instr(file, "</title>")
        title_read = title_end - title_str
        number = number + 1
        response.write(number & ":  ") %><a href=<% response.write(fusionurl & urlfilename) %> target="_blank"><% response.write(mid(file, title_str, title_read)) %></a><%
        starthere = isinfile - 10
       end if
       set readfile=nothing
       set readfilename=nothing
      end if
     arraycounter = arraycounter + 1
    ' set fso=nothing
     set fo=nothing
    ' response.write("Arraycounter = " & arraycounter & " and Counter = " & counter & "<br>")
     if arraycounter = counter then		'if no other folders to search, then done
      response.write("Script Done.<br>")
     else					'if more folders to search, call SubSearch
     end if
    end sub
    It works as long as there are less than about 130 documents. It gives me the error about 9 lines down, set fo = fso.getfolder(path). I made sure to set fo =nothing at the bottom, any ideas why I am getting this? Thanks.
    Last edited by hnugz; 03-01-2006 at 04:18 PM.

  • #2
    New to the CF scene
    Join Date
    Feb 2006
    Thanked 0 Times in 0 Posts
    After many hours of messing around with it, I have come to the conclusion that it is my array that is taking up all the memory. I deleted about 40 of the 160 or so folders but left the files, and the script runs without problems. I tried editing the script where the array never gets larger than maybe 130, but I still get that error. Can anyone see anything wrong with the way the array is done and possibly a way to fix it? Thanks.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts