bstring
Indirection level 1
Character width 1
Length given by 4 byte integer immediately before byte content
Also terminated by 2 null bytes
Garbage collection required
bstring2
Indirection level 1
Character width 2
Length (in bytes) given by 4 byte integer immediately before byte content
Also terminated by 2 null bytes
Garbage collection required
string
Indirection level 2 (1 when passed byval as a parameter)
Character width = 1
Length given by 4 byte integer immediately before byte content
Also terminated by 2 null bytes
Garbage collection automatic
wstring
Indirection level 2 (1 when passed byval as a parameter)
Character width 2
Length given by 4 byte integer immediately before byte content
Also terminated by 2 null bytes
Garbage collection automatic
The main visible difference is the indirection level, but I'm not sure what it means. When is it advisable to use bstring/bstring2 instead of string/wstring?
TIA
OxygenBasic strings are very similar to PowerBasic strings. They are pointers to Bstrings/OLE strings (which are in turn, pointers to blocks of characters as described above )
The extra level of indirection/pointering is used to located an entry in one of the garbage collectors lists. When the string loses its scope, the garbage collector will SysFreeString all the strings on one of its lists.
Internally, there are 3 types of lists:
Temp: for strings used as intermediates in an expression
Local: for strings used in a procedure
Global: for all static and global strings. These are collected when the program or DLL terminates.
string and wstring are the only ones which are automatically garbage collected.
Can we have 64 bit strings with 64 bit LENGTH Charles?
I have seen in PureBasic x64 that the Strings are only 32 bit lenght.
No. You would need to roll your own routines to manage them, and they will be incompatible with any other language and with the operating system.
Quote
string and wstring are the only ones which are automatically garbage collected.
My main interest is to known if I can use a wstring to call a function or COM method that expects a bstring.
Yes, wstrings and bstring2 are handled transparently. Also, inter-conversion between string types is automatic.
With regard to 64bit strings, I can't find any clear advice on allocating >4GB memory blocks, on the web. Which OS calls would you use?
Fundamentals of Garbage Collection MSDN (http://msdn.microsoft.com/en-us/library/ee787088.aspx)
Here is an discussion on that topic:
WinAPI: Allocating large Memory chunks (http://stackoverflow.com/questions/181050/can-you-allocate-a-very-large-single-chunk-of-memory-4gb-in-c-or-c)
Ist hat true?
Somebody says that the total Memory of one running Application can not exceed 8 GB (http://blogs.msdn.com/b/tom/archive/2008/04/10/chat-question-memory-limits-for-32-bit-and-64-bit-processes.aspx) ?
Then this would possibly the limit.
MSDN WindowsOS Memory Limits (http://blogs.msdn.com/b/tom/archive/2008/04/10/chat-question-memory-limits-for-32-bit-and-64-bit-processes.aspx)
Process Memory Limit on x64 (http://stackoverflow.com/questions/2399162/process-memory-limit-of-64-bit-process)
Windows Memory Limits (http://173.194.35.151/url?sa=t&rct=j&q=memory%20limits%20msdn%2064&source=web&cd=8&cad=rja&ved=0CGMQFjAH&url=http%3A%2F%2Foracle.tistory.com%2Fattachment%2Fcfile23.uf%40133C173E4D25480A1C71D4.pdf&ei=lKEuUur9OIbbswb79IEo&usg=AFQjCNE7g02uaOXrUuk-jFpmf0sTCpPLmw&bvm=bv.51773540,d.Yms)