Thursday, 15 September 2011

ruby - What is the lowest memory occupancy object that can be assigned to a variable? -



ruby - What is the lowest memory occupancy object that can be assigned to a variable? -

i want create hash i'm interested in keys. consequence, want values have smallest memory footprint possible. suitable object assign?

nil ? a short symbol :a ? something smaller?

the next applies official ruby implementation. other implementations may differ in regard.

nil, true, false , fixnums encoded within pointer @ c level, whereas other objects involve pointer points somewhere (so you'd have space consumption of pointer plus space points to). these objects ones smallest memory footprint.

of these, nil makes sense semantically.

ruby

No comments:

Post a Comment