Jump to content

TLM Extensions - memory deallocation and clone() and copy_from() functions


Recommended Posts

Hello,

  I am new to TLM and I am looking to implement a model that will be using b_transport() calls with tlm_generic_payload and a custom extension. If we allocate the custom extension objects from the heap, when/where can I safely deallocate the custom extension object?

  Also, while defining the custom extensions, we have to implement clone() and copy_from() functions (inherited form tlm_extension_base). I want to know when do these functions called? In the TLM extension examples I have seen, the clone() function definition includes a call to new() to allocate a new object. Is this clone deallocated (deleted) by the framework/library or is the user responsible for deallocating the clone? If we want to use a memory pool for the extension objects, how can we do that?

Thanks!

Link to comment
Share on other sites

tlm_extension handling is generally the responsibility of the user. The onyl exception here is if you use set_auto_extension(), in this case the extension is deallocated by the generic payload. But this is only to be used with a tlm_mm memory manager.

The same applies to the cloned extensions, clone is use in the deep_copy_from() function of the generic payload.

Link to comment
Share on other sites

44 minutes ago, Eyck said:

tlm_extension handling is generally the responsibility of the user. The onyl exception here is if you use set_auto_extension(), in this case the extension is deallocated by the generic payload. But this is only to be used with a tlm_mm memory manager.

The same applies to the cloned extensions, clone is use in the deep_copy_from() function of the generic payload.

Got it. Thanks!

I just downloaded the Accellera SystemC library code after seeing your reply and looks like deep_copy_from() is not called from any code within the library, users can can use it to deep-copy from one payload object to another. So if I am using set_extension() then after the return from the b_transport(), I can deallocate (or return to the pool) the custom extension object. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...