Hello @AmeyaVS, you can find the results of Valgrind in the attached file (valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all ./Tester). The interesting parts of the report are also shown below.
The insertion of sc_event_timed instances into m_timed_events of sc_simcontext seems to be the problem (sc_event.cpp). These instances are never deleted, so the m_heap of sc_ppq_base is growing very fast (sc_pq.cpp).
If the events are notified in reverse order, it seems that the check
if( m_timed->m_notify_time <= m_simc->time_stamp() + t ) {
return;
}
prevents the insertion.
==18609== HEAP SUMMARY:
==18609== in use at exit: 247,263,893 bytes in 156,323 blocks
==18609== total heap usage: 156,408 allocs, 85 frees, 421,842,196 bytes allocated
...
==18609== 160,000,000 bytes in 156,250 blocks are still reachable in loss record 63 of 63
==18609== at 0x483577F: malloc (vg_replace_malloc.c:299)
==18609== by 0x1112F6: sc_core::sc_event_timed::allocate() (sc_event.cpp:556)
==18609== by 0x111C2B: sc_core::sc_event_timed::operator new(unsigned long) (sc_event.h:381)
==18609== by 0x1102C8: sc_core::sc_event::notify(sc_core::sc_time const&) (sc_event.cpp:161)
==18609== by 0x10FA8E: sc_core::sc_event::notify(double, sc_core::sc_time_unit) (sc_event.h:412)
==18609== by 0x10FD03: Tester::process() (main.cpp:23)
==18609== by 0x12F19C: sc_core::sc_process_b::semantics() (sc_process.h:685)
==18609== by 0x12F6D8: sc_core::sc_method_process::run_process() (sc_method_process.h:305)
==18609== by 0x130E51: sc_core::sc_simcontext::crunch(bool) (sc_simcontext.cpp:486)
==18609== by 0x12C921: sc_core::sc_simcontext::simulate(sc_core::sc_time const&) (sc_simcontext.cpp:887)
==18609== by 0x12E6CC: sc_core::sc_start(sc_core::sc_time const&, sc_core::sc_starvation_policy) (sc_simcontext.cpp:1718)
==18609== by 0x12E7F4: sc_core::sc_start() (sc_simcontext.cpp:1752)
==18609==
==18609== LEAK SUMMARY:
==18609== definitely lost: 0 bytes in 0 blocks
==18609== indirectly lost: 0 bytes in 0 blocks
==18609== possibly lost: 0 bytes in 0 blocks
==18609== still reachable: 247,263,893 bytes in 156,323 blocks
==18609== suppressed: 0 bytes in 0 blocks
valgrind_results.txt