question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[core] How to obtain memory occupied by object ref?

See original GitHub issue

Hi, is there an easy way to get the memory occupied by some object ref? E.g. ray.sizeof(ray.put(object))

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rkooo567commented, Oct 20, 2021

@jmoralez I think right now you can obtain the information using ray.experimental.get_object_locations. Note that this is an experimental API, and the semantics could be changed.

In [3]: @ray.remote 
   ...: def f(): 
   ...:     return 4 
   ...:                                                                                                               

In [4]: r = f.remote()                                                                                                

In [6]: ray.experimental.get_object_locations([r])                                                                    
Out[6]: 
{ObjectRef(a67dc375e60ddd1affffffffffffffffffffffff0100000001000000): {'node_ids': [],
  'object_size': 15}}
1reaction
rkooo567commented, Feb 22, 2021

For now, you can achieve this using ray memory command (it is not programmable api tho). I can take a look if there’s a good way to support this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get object size in memory? [duplicate] - Stack Overflow
One way is to use the GC. GetTotalMemory method to measure the amount of memory used before and after creating your object.
Read more >
Managed Objects and References - Apple Developer
References determine when managed objects are released from memory and also affect what causes them to be retained.
Read more >
Analyze memory usage by using the .NET Object Allocation tool
View how much memory your app uses and what code paths allocate the most memory by using the .NET Object Allocation tool.
Read more >
Measuring Object Sizes in the JVM - Baeldung
5.2. Shallow Size: the Professor Class · Three object references, each of which consumes 4 bytes. So 12 bytes in total for referring...
Read more >
How to interpret ray memory results
Once do_calculation returns, the Plasma memory usage goes to 0 objects and 0.0% ... and once ray.get(result_refs) returns and all local references go...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found