Menu

#143 Add event address in NEW/GC and GC-ATT Q-SPY logs.

QTools
open
5
2020-11-19
2018-06-27
DEBIEF Eric
No

Hi,
Ctxt : QPCPP version : 5.1.1 (Yes quite old).
Looking for a memory leak in my application (one of the pool "leak" one item after thousands of allocation/re-collection), I use Q-SPY to help me on this case.
In the NEW/GC-ATT/GC logs, I only got event information like these :

  • 0000002289 NEW : Evt(Sig=SPI_EXCHANGE_REQUEST_SIG, size= 36)
  • 0000002293 GC : Evt(Sig=SPI_EXCHANGE_REQUEST_SIG, Pool=1, Ref= 1)
  • 0000002293 GC-ATT : Evt(Sig=SPI_EXCHANGE_REQUEST_SIG, Pool=1, Ref= 1)
    This is not enough to check every allocation is associated with a re-collection. So I've simply added the allocated event address in curly brackets.
    Below the associated patches if it can help .
    Regards,
    Eric.

Index: qspy/source/qspy.c

--- qspy.orig/source/qspy.c 2018-06-18 12:19:59.650924606 +0200
+++ qspy/source/qspy.c 2018-06-27 11:24:33.128131173 +0200
@@ -1259,16 +1259,18 @@
t = QSpyRecord_getUint32(me, l_tstampSize);
a = QSpyRecord_getUint32(me, l_evtSize);
c = QSpyRecord_getUint32(me, l_sigSize);

  • p = QSpyRecord_getUint64(me, l_objPtrSize);
    if (QSpyRecord_OK(me)) {
  • SNPRINF_LINE("%010u NEW : Evt(Sig=%s, size=%5u)",
  • SNPRINF_LINE("%010u NEW : Evt(Sig=%s, size=%5u){0x%llx}",
    t,
    SigDictionary_get(&l_sigDict, c, 0, (char *)0),
  • a);
  • a,
  • p);
    QSPY_onPrintLn();

             if (l_matFile != (FILE *)0) {
    
  • fprintf(l_matFile, "%3d %10u %4u %4u\n",

  • (int)me->rec, t, a, c);
  • fprintf(l_matFile, "%3d %10u %4u %4u %llx\n",
  • (int)me->rec, t, a, c, p);
    }
    }
    break;
    @@ -1286,17 +1288,18 @@
    b = QSpyRecord_getUint32(me, 1);
    c = QSpyRecord_getUint32(me, 1);
    }
  • p = QSpyRecord_getUint64(me, l_objPtrSize);
    if (QSpyRecord_OK(me)) {
  • SNPRINF_LINE("%010u %s : Evt(Sig=%s, Pool=%1d, Ref=%2d)",
  • SNPRINF_LINE("%010u %s : Evt(Sig=%s, Pool=%1d, Ref=%2d){0x%llx}",
    t,
    (me->rec == QS_QF_GC_ATTEMPT ? "GC-ATT" : "GC "),
    SigDictionary_get(&l_sigDict, a, 0, (char *)0),
  • b, c);
  • b, c, p);
    QSPY_onPrintLn();

             if (l_matFile != (FILE *)0) {
    
  • fprintf(l_matFile, "%3d %10u %4u %3u %3u\n",

  • (int)me->rec, t, a, b, c);
  • fprintf(l_matFile, "%3d %10u %4u %3u %3u %llx\n",
  • (int)me->rec, t, a, b, c, p);
    }
    }
    break;

diff --git a/QP/qf/source/qf_new.cpp b/QP/qf/source/qf_new.cpp
index 074f543..1f37b4a 100644
--- a/QP/qf/source/qf_new.cpp
+++ b/QP/qf/source/qf_new.cpp
@@ -58,13 +58,6 @@
}
Q_ASSERT(idx < QF_maxPool_); // cannot run out of registered pools

  • QS_CRIT_STAT_
  • QS_BEGIN_(QS_QF_NEW, null_void, null_void)
  • QS_TIME_(); // timestamp
  • QS_EVS_(evtSize); // the size of the event
  • QS_SIG_(static_cast<qsignal>(sig)); // the signal of the event</qsignal>
  • QS_END_()

    QEvt *e;
    QF_EPOOL_GET_(QF_pool_[idx], e, margin); // get e -- platform-dependent
    if (e != null_evt) { // was e allocated correctly?
    @@ -75,6 +68,14 @@
    else {
    Q_ASSERT(margin != u16_0); // must tollerate bad allocation
    }

  • QS_CRIT_STAT_
  • QS_BEGIN_(QS_QF_NEW, null_void, null_void)
  • QS_TIME_(); // timestamp
  • QS_EVS_(evtSize); // the size of the event
  • QS_SIG_(static_cast<qsignal>(sig)); // the signal of the event</qsignal>
  • QS_OBJ_(e); // The event address
  • QS_END_()
    +
    return e;
    }

diff --git a/QP/qf/source/qf_gc.cpp b/QP/qf/source/qf_gc.cpp
index a5ee71a..bcf8a94 100644
--- a/QP/qf/source/qf_gc.cpp
+++ b/QP/qf/source/qf_gc.cpp
@@ -56,6 +56,7 @@
QS_TIME_(); // timestamp
QS_SIG_(e->sig); // the signal of the event
QS_2U8_(e->poolId_, e->refCtr_);// pool Id & refCtr of the evt

  • QS_OBJ_(e); //The event address
    QS_END_NOCRIT_()

         QF_CRIT_EXIT_();
    

    @@ -67,6 +68,7 @@
    QS_TIME_(); // timestamp
    QS_SIG_(e->sig); // the signal of the event
    QS_2U8_(e->poolId_, e->refCtr_);// pool Id & refCtr of the evt

  • QS_OBJ_(e); //The event address
    QS_END_NOCRIT_()

         QF_CRIT_EXIT_();
    

Discussion

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB