本文簡要介紹ruby語言中  ObjectSpace.memsize_of_all  的用法。
用法
memsize_of_all([klass]) → Integer
返回所有活動對象的消耗內存大小(以字節為單位)。
如果給出klass(應該是 Class  object),則返回給定類的實例的總內存大小。
請注意,返回的大小不完整。您隻需要將此信息作為提示來處理。特別是T_DATA 的大小可能不正確。
請注意,此方法不會返回 malloc 的總內存大小。
該方法可以通過以下 Ruby 代碼定義:
def memsize_of_all klass = false
  total = 0
  ObjectSpace.each_object{|e|
    total += ObjectSpace.memsize_of(e) if klass == false || e.kind_of?(klass)
  }
  total
end
此方法僅適用於 C Ruby。
相關用法
- Ruby ObjectSpace.count_symbols用法及代碼示例
 - Ruby ObjectSpace.define_finalizer用法及代碼示例
 - Ruby ObjectSpace.count_imemo_objects用法及代碼示例
 - Ruby ObjectSpace.allocation_generation用法及代碼示例
 - Ruby ObjectSpace.each_object用法及代碼示例
 - Ruby ObjectSpace.reachable_objects_from用法及代碼示例
 - Ruby ObjectSpace.allocation_class_path用法及代碼示例
 - Ruby ObjectSpace.count_objects_size用法及代碼示例
 - Ruby ObjectSpace.count_nodes用法及代碼示例
 - Ruby ObjectSpace.trace_object_allocations用法及代碼示例
 - Ruby ObjectSpace.count_objects用法及代碼示例
 - Ruby ObjectSpace.count_tdata_objects用法及代碼示例
 - Ruby ObjectSpace.allocation_method_id用法及代碼示例
 - Ruby ObjectSpace模塊用法及代碼示例
 - Ruby Object.instance_variable_get用法及代碼示例
 - Ruby Object.display用法及代碼示例
 - Ruby Object.remove_instance_variable用法及代碼示例
 - Ruby Object.define_singleton_method用法及代碼示例
 - Ruby Object.methods用法及代碼示例
 - Ruby Object.public_send用法及代碼示例
 - Ruby Object.xmp用法及代碼示例
 - Ruby Object.singleton_methods用法及代碼示例
 - Ruby Object.enum_for用法及代碼示例
 - Ruby Object.freeze用法及代碼示例
 - Ruby Object.inspect用法及代碼示例
 
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 ObjectSpace.memsize_of_all。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
