Question for Rob on memory usage
- Posted by Andy Serpa <renegade at earthling.net> May 16, 2002
- 374 views
Hello, Let's say: seq_A = "This is sequence A." Now I know if I do this: seq_B = seq_A Euphoria doesn't actually copy the sequence into a new memory location, just points to the existing one for A unless one of them is altered. That's good. But what if I do this? seq_A = append(seq_A,seq_A) Now A has two copies of the same thing. Does it take up twice as much memory now, or do I get the same efficiency as before? If it takes extra memory, would doing this be any better: seq_B = {seq_A,seq_A} ? If those DON'T take up any extra memory, can I also do this: seq_A = append(seq_A,seq_A[1]) ? and STILL not use up any extra? (Obviously you have to store the structure somewhere in memory -- I'm talking about for the elements themselves). I'm working on a program where having multiple copies of the same thing at different indexes will be convienent, but I don't want to be using up the extra memory because some of the items will be quite large. You can assume that although the sequence may be appended to, none of the individual elements of the sequence will be altered once created. It will also be convenient to append to a sequence and element that occurs earlier in the sequence. I could use some sort of pointer system and just store indexes that refer to another sequence, but the first way is easier if it doesn't matter. ????