Question

I'm using a long, concatenated String variable and doing a process on that variable. I need to know when the size in memory can become too large, so I need to find the size in memory of that string. Is there a way, and if so how so?

Dim str As String = someLargeAmountOfText
process(str)
Was it helpful?

Solution

You can use the LenB function to find out how many bytes the string takes up. More information at http://docs.realsoftware.com/index.php/LenB

Dim str As String = someLargeAmountOfText
Dim iLength As UInt64 = str.lenB
If iLength <= somevalue Then
   Process(str)
End If

OTHER TIPS

A MemoryBlock can also be used to get the size of memory used by a String:

Dim s As String = "abcde"
Dim mb As MemoryBlock
mb = s
Dim size As UInt64 = mb.Size
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top