Re: Store characters in memory
- Posted by jimcbrown (admin) Sep 30, 2009
- 1106 views
Hello, I recently tried to store a lot of pics and utf-8 text in memory for quick access. So they are all small integers range from 0 to 255. Since integers are stored as 4-byte in Euphoria, it takes 200KB memory to store a 50KB pic, huge overhead.
So I tried to pack 3 integers into a big one (4 would become an atom), still they are 4/3 larger and it takes considerably time to "encode" and "decode" them. Is there some way they can be stored in compact form, like in the EDS?
For this you are probably best off using raw memory blocks.
If you are using 4.0 you can use the new eumem library, otherwise you will have to deal with allocate() and free().
I highly recommend using bernie ryan's memcpy library. He handles the hard part of raw memory access for you.
Oops, its called mixedlib. Available here:
http://www.RapidEuphoria.com/mixedlib.zip