Frage

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)
War es hilfreich?

Lösung

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

Andere Tipps

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
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top