From: 7stud -- Date: 2008-04-07T13:29:21+09:00 Subject: Re: Do arrays use up alot of memory space? Clement Ow wrote: > -------------------------------------------------------------------------------- > $options= > ["2008*", "2008*", "700*", "2008*", "2008*"] > > $source= > %w[C:/movtest/testing > C:/movtest/testing/new > U:/movtest/source > U:/movtest/new > U:/movtest/new1] > > $dest= > %w[U:/test_1/ > U:/dest1/ > U:/dest2/ > U:/dest3/ > U:/dest4/] > You have 3 arrays with 5 short strings in them. A character in a string takes up 1 byte of memory. I don't know exactly what the overhead for an array is, but it is comparatively tiny--although you never know with ruby. I would guess all your arrays would take up less than 1,000 bytes or 1 kB in memory. That's tiny. > while i<=j && i1<=j1 && i2<=j2 > > Dir.chdir($source[i]) > print "\nSource: " + Dir.getwd + "\t\n" > print "Dest: " + $dest[i1] + "\n" > print "Options: " + $options[i2] +"\n" > FileUtils.cp_r Dir.glob($options[i2]), $dest[i1] > print "File Mov Test:Success" > i+=1 > i1+=1 > i2+=1 > end > > -------------------------------------------------------------------------------- > Apparently, when moving large files (i.e file size 50mb) it takes > relatively long as when i use ROBOCOPY (a robust copying software by > MSServer), but I cant use robocopy because it has it's limitations,hence > i used ruby. As I will be running the ruby program on a server, I cant > afford to use too much memory while transferring files from one folder > to another as the server is used for more impt tasks like running impt > applications in the office. > > So is there anything that i could do to quicken the copying process > without compromising on the ability to have different path names and > options for copying files? (i understand that arrays do take up more > memory) > Thanks in advance. =) -- Posted via http://www.ruby-forum.com/.