草庐IT

newCString

全部标签

memory - 释放用 newCString 分配的内存

正如库文档所说,使用newCString创建的CString必须使用free函数释放。我一直期待在创建CString时会占用一些内存,而当使用free释放它时,内存使用率会下降,但事实并非如此!这是示例代码:moduleMainwhereimportForeignimportForeign.C.StringimportSystem.IOwait=doputStr"Pressenter">>hFlushstdout_当程序在(1)处停止时,htop程序显示内存使用量在410M左右-这没关系。我按回车,程序在第(2)行停止,但尽管cs已freed!,但内存使用量仍为410M这怎么可能?用C