Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » DSDP - Real-Time Software Components (RTSC) » Iterate over all heap instances?
Iterate over all heap instances? [message #537582] Thu, 03 June 2010 02:08 Go to next message
Chris Ring is currently offline Chris RingFriend
Messages: 16
Registered: July 2009
Location: Santa Barbara, CA
Junior Member
Is there a way to, at runtime, iterate over all heap instances?

My concrete use case is to periodically call Memory_getStats() on all heap instances to determine the memory usage in my app, as well as detect any memory leaks when it completes. The first arg to Memory_getStats() is a heap instance handle, so I'm looking to enumerate all the heap instance handles and call Memory_getStats() on each one.

Thanks.
Re: Iterate over all heap instances? [message #537791 is a reply to message #537582] Thu, 03 June 2010 16:00 Go to previous messageGo to next message
Dave Russo is currently offline Dave RussoFriend
Messages: 172
Registered: July 2009
Senior Member
On 6/2/2010 7:08 PM, Chris Ring wrote:
> Is there a way to, at runtime, iterate over all heap instances?
>
Yes. You need to know the module to get the instances, however. Every
module that manages instances provides a function that allows one to
iterate over all dynamic (or static) instances.

See http://rtsc.eclipse.org/docs-tip/C_-_Object_first

> My concrete use case is to periodically call Memory_getStats() on all
> heap instances to determine the memory usage in my app, as well as
> detect any memory leaks when it completes. The first arg to
> Memory_getStats() is a heap instance handle, so I'm looking to enumerate
> all the heap instance handles and call Memory_getStats() on each one.
>
> Thanks.
Re: Iterate over all heap instances? [message #537815 is a reply to message #537791] Thu, 03 June 2010 17:45 Go to previous messageGo to next message
Chris Ring is currently offline Chris RingFriend
Messages: 16
Registered: July 2009
Location: Santa Barbara, CA
Junior Member
Thanks. Doesn't quite meet my use case, though. By design(!) I have no idea what Modules will in my system when I compile my library.

Maybe I can, in my meta-only module's .xdt file, loop over all Modules in the system that inherit from IHeap and somehow generate a function that does what I need. (I can't find all Modules that inherit from IHeap at runtime, can I?)

Given all the <Mod>'s that inherit IHeap, I guess I can then use <Mod>_Object_first()/next() for any dynamic instances and <Mod>_Object_count()/get() for the static instances. Given all that, I could probably call this autogenerated fxn.

Any other suggestions? This isn't trivial to put together, and if there's an easier way, I'm looking for it. Rolling Eyes Thanks in advance.
Re: Iterate over all heap instances? [message #537871 is a reply to message #537815] Fri, 04 June 2010 00:05 Go to previous messageGo to next message
Dave Russo is currently offline Dave RussoFriend
Messages: 172
Registered: July 2009
Senior Member
On 6/3/2010 10:45 AM, Chris Ring wrote:
> Thanks. Doesn't quite meet my use case, though. By design(!) I have no
> idea what Modules will in my system when I compile my library.
>
> Maybe I can, in my meta-only module's .xdt file, loop over all Modules
> in the system that inherit from IHeap and somehow generate a function
> that does what I need. (I can't find all Modules that inherit from IHeap
> at runtime, can I?)
Right (and Right)
>
> Given all the <Mod>'s that inherit IHeap, I guess I can then use
> <Mod>_Object_first()/next() for any dynamic instances and
> <Mod>_Object_count()/get() for the static instances. Given all that, I
> could probably call this autogenerated fxn.
Right.
>
> Any other suggestions? This isn't trivial to put together, and if
> there's an easier way, I'm looking for it. :roll: Thanks in advance.
Unfortunately, there is no better way today. Although it is possible to
create the data structures to scan all instances that are created by
modules that inherit a specific interface this would result in a fair
amount of data in systems that don't need (and can't afford) the overhead.

Obviously this can can a configurable option. Contributions are welcome.
Re: Iterate over all heap instances? [message #538052 is a reply to message #537582] Fri, 04 June 2010 16:52 Go to previous message
Dave Russo is currently offline Dave RussoFriend
Messages: 172
Registered: July 2009
Senior Member
FWIW: The first heap example in the RTSC-pedia illustrates a technique
for monitoring memory and checking for memory leaks/overflow and uses
the Object_get() methods to loop over all instances of a heap module:
http://rtsc.eclipse.org/docs-tip/Extending_xdc.runtime_Memor y/Example_1


On 6/2/2010 7:08 PM, Chris Ring wrote:
> Is there a way to, at runtime, iterate over all heap instances?
>
> My concrete use case is to periodically call Memory_getStats() on all
> heap instances to determine the memory usage in my app, as well as
> detect any memory leaks when it completes. The first arg to
> Memory_getStats() is a heap instance handle, so I'm looking to enumerate
> all the heap instance handles and call Memory_getStats() on each one.
>
> Thanks.
Previous Topic:Release notification for XDCtools 3.20
Next Topic:Directing a section to multiple segments
Goto Forum:
  


Current Time: Tue Apr 23 13:27:42 GMT 2024

Powered by FUDForum. Page generated in 0.03745 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top