Re: Sequence compression question.
- Posted by Robert Craig <rds at RapidEuphoria.com> Dec 16, 2003
- 489 views
Hayden McKay wrote: > How much memory does a sequence use. > for example how much memory is allocated for an empty sequence. And how > much memory is used for a sequence of say 4 subscripts and is > there extra empty memory being allocated. > > The reason I ask, is that I have a method similer to formula converting > binary into decimal, to compress single words in a string to single > integers in a sequence, then convert back to a string of words. Would > this actualy save much memory for stored strings? If you look at euphoria\include\euphoria.h, you'll see a C structure called struct s1. (There used to be a struct s2, but it was eliminated years ago.) struct s1 has 4 fields of size 4 bytes each. This 16-byte structure appears as the header of all sequences. The elements of a sequence are always 4 bytes, even if they represent very small integers. Floating-point numbers and sequences are represented by 4-byte pointers to other blocks of data. Of course, anything that is allocated from the heap will have other storage overheads, e.g. the size of the allocated block, or some filler space to get the desired alignment in memory, etc. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com