• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Release memory after a function is completed

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 142
  • Views 13993
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Release memory after a function is completed

crizos
crizos over 7 years ago

Hi all,

Assume that we have a dummy test function which its definition is:

procedure( test() let( (x) x = list( 2 3 ) ) )


If I run the profiler for this procedure I see that the total memory that have been allocated for this function is 96 bytes, while list command needs 48 bytes. Let's say that we need this function to be used 10000 consecutive times for a reason. Profiler reports that the allocated memory for this operation raises up to 468 KByte because of list command which need this much amount of bytes (I guess the numbers may differ in different machines).

Is it possible to reduce the memory that is captured for this operation in any way? Or make that memory available again after the operation is finished? memoryAllocated() function indicates that once my processes are over, the memory remains captive.

Also, I tried to force-use the gc() function but with no results, while operated time was increased.

 

Chris

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 7 years ago

    Hi Chris,

    You generally do not need to worry about this, as the system will garbage collect automatically as it needs to. Essentially it keeps a pool of each kind of object (list cells in this case) and when it has run out, it triggers a garbage collection before allocating more. Calling gc() explicitly is something that should only rarely be done in some high memory applications if you really need to control precisely when garbage collection occurs, but in general I wouldn't advise calling it in a program.

    Note that the memory won't be returned to the OS - so you wouldn't expect memoryAllocated() to reduce. Any unreferenced list cells are available to be garbage collected and re-used in subsequent operations. Many applications in Linux and other UNIX systems are similar - freeing memory doesn't necessarily return it to the OS.

    Trying to optimise memory in such a simple situation is unlikely to be worth the effort, similar to it being pointless doing performance optimisation at too low a level (or too soon). There are of course efficient ways of processing large amounts of data which can minimise potential garbage, but that's not something you can really extrapolate from such a trivial example as this.

    Kind Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • crizos
    crizos over 7 years ago in reply to Andrew Beckett

    Hi Andrew,

    In a way, this example is not so far from the reality, but thank you for the answer.

    Sincerely,

    Chris

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information