PDA

View Full Version : Limitation of dynamic string buffers for Zic2410


telmo
08-24-2010, 07:14 AM
The reference manual for version 2.4(or version 2.2) says "There is limited dynamic memory in SNAPpy" in page 85/159 ,but what's the length limitation?
And the reference manual says "Functions that manipulate strings all pull from a small pool of dynamic (reusable) string buffers.", i want to know will the second string (concatenation for example) will overwrite the first string of the same kind when the total string length of the two doesn't exceed the limitation.And what about the situation when the second string's type is not the same as the first one? I think the answer is "no".So can i say:" Only will the first string be overwritten when the total string length of all string varibles exceeds the length limitation of the dynamic memory"?

Thanks in advance!

Jheath
08-24-2010, 08:44 AM
The limitations for dynamic string sizes are specific to each hardware platform. The SNAP Reference Manual lists these in the sections near the end that discuss each implementation.

For Example, with the RF100 (Freescale Based):
SNAPpy Virtual Machine Memory Usage
Number of Tiny Strings: 7
Tiny String Size: up to 8 characters
Number of Medium Strings: 6
Medium String Size: up to 62 characters
Global Variables: 64
Concurrent Local Variables: 64

The strings will not "overwrite" one another once all the available memory has been allocated. Instead, SNAPpy will present an error (see errno() function for list of all error codes) along the lines of "MAX_STRING_SIZE_EXCEEDED" (Error #21) or #18 "ALLOC_FAIL".

You will also get an error when comparing dissimilar data types (4 = INCOMPATIBLE_TYPES). However, Python is setup such that variable types can change on the fly depending on the value being assigned

telmo
08-24-2010, 11:02 AM
For Example, with the RF100 (Freescale Based):
SNAPpy Virtual Machine Memory Usage
Number of Tiny Strings: 7
Tiny String Size: up to 8 characters
Number of Medium Strings: 6
Medium String Size: up to 62 characters
Global Variables: 64
Concurrent Local Variables: 64


So for RF100(Freescale Based),if the size of my string >8 characters the Virtual Machine will explain it as a "Medium String",and it can be 62-character long,right?
And the maxium number of such "Medium String" is 6,no matter how many characters each of the six string take up?

kbanks
08-24-2010, 05:41 PM
Yes, SNAPpy will switch from a small buffer to a medium buffer if the string grows too big to fit in a small buffer.

SNAPpy will also use a medium buffer instead of a small buffer (even if the string is short enough to fit in a small buffer) if all the small string buffers are already in use.

Yes, there are only a fixed number of medium buffers. It does not matter if you have 6 10 character strings or 6 60 character strings.

telmo
08-24-2010, 08:33 PM
Yes, SNAPpy will switch from a small buffer to a medium buffer if the string grows too big to fit in a small buffer.

SNAPpy will also use a medium buffer instead of a small buffer (even if the string is short enough to fit in a small buffer) if all the small string buffers are already in use.

Yes, there are only a fixed number of medium buffers. It does not matter if you have 6 10 character strings or 6 60 character strings.

clear and concise answer!Thanks a lot!

Yes, there are only a fixed number of medium buffers. It does not matter if you have 6 10 character strings or 6 60 character strings.
If i have 6 10-character strings , there remains a lot of unused dynamic string space.What a waste!