I'm afraid my example was too theoretic... and a bit missleading...
I have a ByteArray which contains, for example, a stream of 2 PNGs and 1 MP3, each around 2MB
I run this code (not using workers at all):
byteArray.readBytes(png1, png1_start, png1_end);
byteArray.readBytes(png2, png2_start, png2_end);
byteArray.readBytes(mp3, mp3_start, mp3_end);
That ends with creating 3 new ByteArrays in memory from the source ByteArray.
That also ends with choking my frame with 6MB memory allocation. and we all know how bad Flash behaves with allocating memory on frame.
Flash should offer something like 'readBytesShareMemory', which would create a new ByteArray that uses the same underlying system memory,,
The 'String' class is a good example of memory sharing... method 'substring' never creates new memory, but just tell the new String how to offset and length the underlying, shared memory.
hydroper
your idea is interesting, I could try and extend ByteArray (it's not a final class), and reuse the source ByteArray... but system classes want ByteArray (Sound.loadCompressedDataFromByteArray or Texture.fromAtfData)
I'm still surprised there isn't any good solution for this...