Jump to content
Lukas Steiner

Memory leak when sc_event is notified twice

Recommended Posts

The SystemC standard says:

5.10.8 Multiple event notifications
A given event shall have no more than one pending notification.
If function notify is called for an event that already has a notification pending, only the notification
scheduled to occur at the earliest time shall survive. The notification scheduled to occur at the later time
shall be cancelled (or never be scheduled in the first place). An immediate notification is taken to occur
earlier than a delta notification, and a delta notification earlier than a timed notification. This is irrespective
of the order in which function notify is called.

If I run the following example the simulation stops after 100000000 ps as intended, however, the memory usage of the program increases rapidly to 1GB and more. 

#include <iostream>
#include <systemc.h>

    sc_event event;
    uint64_t counter = 0;

        sensitive << event;

    void process()
        if (counter == 100000000)


        event.notify(1, SC_MS);
        event.notify(1, SC_PS);

int sc_main(int argc, char **argv)
    Tester tester("Tester");

    return 0;

When both event notifications are swapped the memory leak is gone. When SC_MS is replaced by SC_US, the memory usage increases a lot slower.

The program was tested with the latest SystemC version from GitHub as well as SystemC 2.3.3 on the WSL with GCC 8 and GCC 6.

Share this post

Link to post
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.

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...