【问题标题】:How to get the size, in memory, of a string variable in REALbasic?如何在内存中获取 REALbasic 中字符串变量的大小?
【发布时间】:2012-11-28 02:59:19
【问题描述】:

我正在使用一个长的连接字符串变量并对该变量进行处理。我需要知道内存中的大小何时会变得太大,因此我需要找到该字符串在内存中的大小。有没有办法,如果有怎么办?

Dim str As String = someLargeAmountOfText
process(str)

【问题讨论】:

    标签: memory-management realbasic


    【解决方案1】:

    您可以使用 LenB 函数找出字符串占用了多少字节。更多信息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
    

    【讨论】:

      【解决方案2】:

      MemoryBlock 也可用于获取 String 使用的内存大小:

      Dim s As String = "abcde"
      Dim mb As MemoryBlock
      mb = s
      Dim size As UInt64 = mb.Size
      

      【讨论】:

        猜你喜欢
        • 2017-10-30
        • 2015-01-14
        • 1970-01-01
        • 2011-06-25
        • 1970-01-01
        • 1970-01-01
        • 2020-10-17
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多