News:

  • October 01, 2025, 11:59:19 AM

Login with username, password and session length

Author Topic: Heaps  (Read 1825 times)

PLCGuy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 677
Heaps
« on: July 03, 2018, 06:45:38 AM »
Is there more info on this subject of Heaps. I am creating and using memory blocks, but do not fully understand the Heaps, etc. So I do not use the tabs.
I am reading the help files but it is just not sinking in. I did find some examples for recipes. Reading over that. Not sure why I am not getting it.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Heaps
« Reply #1 on: July 03, 2018, 07:03:08 AM »
Instead of having a named block of structures that you reference by block name and 0-based id, a heap item is just one element, no id.  Some PLCs call this a Tag.  So instead of a block of 10 or 100 PIDs, you can create a single PID heap item with a well named tag called "MyHeater"

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6123
  • Yes Pinky, Do-more will control the world!
Re: Heaps
« Reply #2 on: July 03, 2018, 09:00:24 AM »
Blocks are numbered arrays, heap items are singletons. As Franj said, tags.

Background: The heap was originally created as a place where the system could create elements outside of normal element memory. For instance, if you had a CTRIO module, we needed a place to automatically create the structures associated with it. That worked well, so we made instructions that needed structures (like PID or TASK) do the same thing. Eventually we made it where users could create items there as well.

While the system creates lots of stuff on the heap for me, about the only time I create something directly on the heap is if I need a big string for something like a comm buffer. I usually create a 1024 byte string with a name like CommBuff, rather than a block named SLL0.

The bottom line is that you may never use it directly, and that's fine.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO