看板 C_Sharp 關於我們 聯絡資訊
※ 引述《virdust2003 (替機殼洗個熱水澡)》之銘言: : http://www.codeproject.com/dotnet/strings.asp : 文章中介紹的 SetLength 不知道會不會造成 Memory leaking 的問題 : 除非 GC 是使用 Capacity 去回收,但想想使用 capacity去回收也沒什麼錯 我不清楚 C# 的 GC 回收方式, 但應該是解構整個物件, 釋放記憶體 : 還有 為什麼 : 'Good morning' has capacity 17, length 12 : 是17啊? 是加了 m_currentThread 、m_MaxCapacity 嗎? 要考慮 StringBuilder 預設的 capacity 是16, 再加上 \0 就是17 文中有說 capacity 比字串大二倍以上, 才會縮減並重新建立新 string 來輸出 程式是取得 string 的 m_arrayLength int *pcapacity = (int *)p - 2; -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.104.235.206
virdust2003:恩,忘了16 12/10 00:41