|
-
October 15th, 2012, 02:00 AM
#5
Re: Array subset
 Originally Posted by TheGreatCthulhu
Can you describe what you're trying to do in more detail?
Hi!
one of my classes that takes care of socket communication between devices returns an array (byte []) containing a whole message. The message consists of some initial bytes and then a data part. A need to operate to the data part without loss of performances due to Copy stuff (and actually I don't need a copy for any other reason). I represent the message here as follows:
[P] [P] [P] [P] [P] [D] [D] [D] ... [D] [D] [D] [CHK]
[P] bytes are the bytes needed by protocol communication
[D] bytes are the "sub buffer" of data bytes
[CHK] final checksum
The thing is that for every message that arrives I now create a copy of the data bytes to create an array that contains only the [D] bytes.
I need to use the sub buffer for every futher management of the data, after the message arrives. I do not need the [P] bytes anymore, after the message is decoded.
On a Desktop PC machine everything works fine, but when the application is run on a PDA, all of those useless copies consume a lot in matter of RAM and CPU-time, sometimes the PDA goes also into OutOfMemoryException. Consider that my message is usually composed by a few [P] bytes and many [D] bytes. For example a message might be 5000 bytes and only 10 of them are [P] bytes.
That is why I would like to operate onto the original array and not onto a copy of it. I understand now that this may not by possible in C#. Everything would have been much easier in C++ when you could simply use a pointer to a byte in the middle as an array of bytes and pass it as an argument of array of byte.
Last edited by MontgomeryBurns; October 15th, 2012 at 04:33 AM.
Mr. Burns
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|