Re: memory

new topic     » goto parent     » topic index » view thread      » older message » newer message

> I have a short program that opens a 6.8megabyte file, containing text
> separated by lots of {0}. The object is to eliminate the {zero}s, and
reformat
> the results to a more text-looking file. What i can't figure is that
Taskinfo
> says Eu is using 86Megabytes in memory to do it!
>
> Are these the lines doing it? Is a new instance of data created every time
it
> is mentioned in the line?:
>
> puts(1,"removing 10 nulls\n")
> place = match({0,0,0,0,0,0,0,0,0,0},data)
> while place do
>  data = data[1..place] & data[place+10..length(data)]
>  place = match({0,0,0,0,0,0,0,0,0,0},data)
> end while

Hi Kat,
I suspect something like that is happening. As a rule, I try never to
re-create an existing sequence because of all the copies that Eu might make
of it.

Try this instead...

  puts(1,"removing 10 nulls\n")
  place = match({0,0,0,0,0,0,0,0,0,0},data)
  dataend = length(data)
  while place > 0 and place < dataend do
     data[place .. dataend - 10] = data[place+10 .. dataend]
     dataend -= 10
     place = match({0,0,0,0,0,0,0,0,0,0},data)
  end while
  data = data[1 .. dataend]

the difference is that this overwrites existing elements in 'data' during
the removal phase and then truncates the extra stuff at the end. It should
also be a lot faster.

----- Original Message -----
From: "Kat" <gertie at PELL.NET>
To: "EUforum" <EUforum at topica.com>
Sent: Thursday, July 12, 2001 5:13 PM
Subject: memory

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu