本文簡要介紹ruby語言中 IO::Buffer.free
的用法。
用法
free → self
如果緩衝區引用內存,則將其釋放回操作係統。
-
對於
mapped
緩衝區(例如,來自文件):取消映射。 -
對於從頭開始創建的緩衝區:空閑內存。
-
對於從字符串創建的緩衝區:撤消關聯。
釋放緩衝區後,無法對其執行進一步的操作。
buffer = IO::Buffer.for('test')
buffer.free
# => #<IO::Buffer 0x0000000000000000+0 NULL>
buffer.get_value(:U8, 0)
# in `get_value': The buffer is not allocated! (IO::Buffer::AllocationError)
buffer.get_string
# in `get_string': The buffer is not allocated! (IO::Buffer::AllocationError)
buffer.null?
# => true
您可以調整已釋放緩衝區的大小以重新分配它。
相關用法
- Ruby Buffer.for用法及代碼示例
- Ruby Buffer.slice用法及代碼示例
- Ruby Buffer.set_value用法及代碼示例
- Ruby Buffer.external?用法及代碼示例
- Ruby Buffer.new用法及代碼示例
- Ruby Buffer.locked?用法及代碼示例
- Ruby Buffer.transfer用法及代碼示例
- Ruby Buffer.map用法及代碼示例
- Ruby Buffer.clear用法及代碼示例
- Ruby Buffer.copy用法及代碼示例
- Ruby Buffer.locked用法及代碼示例
- Ruby Buffer.get_value用法及代碼示例
- Ruby Buffer.get_string用法及代碼示例
- Ruby Buffer.to_s用法及代碼示例
- Ruby Buffer.resize用法及代碼示例
- Ruby Buffer類用法及代碼示例
- Ruby Buffering.read_nonblock用法及代碼示例
- Ruby Buffering.write_nonblock用法及代碼示例
- Ruby Bundler.setup用法及代碼示例
- Ruby Bundler模塊用法及代碼示例
- Ruby Bundler.require用法及代碼示例
- Ruby Bundler.definition用法及代碼示例
- Ruby BigMath.cos用法及代碼示例
- Ruby Binding.local_variable_defined?用法及代碼示例
- Ruby BigDecimal.self >用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 Buffer.free。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。