<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Please advise where is the memory leak in my pro*c in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/please-advise-where-is-the-memory-leak-in-my-pro-c/m-p/4242575#M677161</link>
    <description>void DBUser::LoadCollection(CollectionBase&lt;DMOUSER&gt;&amp;amp; collection)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;    EXEC SQL BEGIN DECLARE SECTION;&lt;BR /&gt;        struct sqlca sqlca;&lt;BR /&gt;    EXEC SQL END DECLARE SECTION;&lt;BR /&gt;&lt;BR /&gt;    memset(&amp;amp;sqlca, 0, sizeof(sqlca));&lt;BR /&gt;&lt;BR /&gt;    DmoUser *user = NULL;&lt;BR /&gt;&lt;BR /&gt;    //----------------------------------------------------&lt;BR /&gt;    // Thread Based Arrays to Support Multithreaded Mode&lt;BR /&gt;    //----------------------------------------------------&lt;BR /&gt;    EXEC SQL BEGIN DECLARE SECTION;&lt;BR /&gt;        struct UserRec *user_rec_ptr;&lt;BR /&gt;        struct UserInd *user_ind_ptr;&lt;BR /&gt;    EXEC SQL END DECLARE SECTION;&lt;BR /&gt;&lt;BR /&gt;    UserRec&amp;amp; user_rec = userRec[pthread_self()];&lt;BR /&gt;    user_rec_ptr = &amp;amp;user_rec;&lt;BR /&gt;&lt;BR /&gt;    UserInd&amp;amp; user_ind = userInd[pthread_self()];&lt;BR /&gt;    user_ind_ptr = &amp;amp;user_ind;&lt;BR /&gt;&lt;BR /&gt;    EXEC SQL WHENEVER SQLERROR DO SqlError( "DBUser::LoadCollection() error\n", sqlca);&lt;BR /&gt;&lt;BR /&gt;    //--------------------------&lt;BR /&gt;    // Get a SQL Context&lt;BR /&gt;    //--------------------------&lt;BR /&gt;    TRACELOG( TRACE_SYS_DB, "DBUser::LoadCollection Getting context");&lt;BR /&gt;    sql_context *ctx;&lt;BR /&gt;    ctx = DBMultiThreadSingleton::GetThreadContext();&lt;BR /&gt;    EXEC SQL CONTEXT USE :*ctx;&lt;BR /&gt;&lt;BR /&gt;    //--------------------------------------&lt;BR /&gt;    // Declare and allocate cursor variable.&lt;BR /&gt;    //--------------------------------------&lt;BR /&gt;    DBCursor dbCursor;&lt;BR /&gt;    EXEC SQL BEGIN DECLARE SECTION;&lt;BR /&gt;        SQL_CURSOR *user_cv = &amp;amp;dbCursor;&lt;BR /&gt;    EXEC SQL END DECLARE SECTION;&lt;BR /&gt;&lt;BR /&gt;    //---------------------------------&lt;BR /&gt;    // Open users cursor&lt;BR /&gt;    //---------------------------------&lt;BR /&gt;    EXEC SQL EXECUTE&lt;BR /&gt;    BEGIN&lt;BR /&gt;        users_pkg.get_users(:user_cv);&lt;BR /&gt;    END;&lt;BR /&gt;    END-EXEC;&lt;BR /&gt;&lt;BR /&gt;   //---------------------------------&lt;BR /&gt;    // Fetch and process user_cv rows&lt;BR /&gt;    // Close user_cv cursor&lt;BR /&gt;    //---------------------------------&lt;BR /&gt;    try&lt;BR /&gt;    {&lt;BR /&gt;        // Break when no more rows&lt;BR /&gt;        EXEC SQL WHENEVER NOT FOUND DO break;&lt;BR /&gt;&lt;BR /&gt;        for (;;)&lt;BR /&gt;        {&lt;BR /&gt;            EXEC SQL FETCH :user_cv&lt;BR /&gt;                INTO :user_rec_ptr INDICATOR :user_ind_ptr;&lt;BR /&gt;&lt;BR /&gt;            user = new DmoUser;&lt;BR /&gt;&lt;BR /&gt;            //----------------------&lt;BR /&gt;            // Populate data members&lt;BR /&gt;            //----------------------&lt;BR /&gt;            user-&amp;gt;SetUserID(user_rec.user_id);&lt;BR /&gt;            user-&amp;gt;SetLoginID(VARCHAR_TO_STR(user_rec.user_login_id));&lt;BR /&gt;            user-&amp;gt;SetSecurityProfilePk( IntVal(user_rec.security_profile_pk,&lt;BR /&gt;                                               user_ind.security_profile_pk_ind) );&lt;BR /&gt;            user-&amp;gt;SetUserName(VARCHAR_TO_STR(user_rec.user_name));&lt;BR /&gt;            user-&amp;gt;SetSPID(VARCHAR_TO_STR(user_rec.user_group));&lt;BR /&gt;&lt;BR /&gt;            StrToTime(user-&amp;gt;_userCreationTS, user_rec.user_creation_ts,&lt;BR /&gt;                        user_ind.user_creation_ts_ind);&lt;BR /&gt;            StrToTime(user-&amp;gt;_lastLoginTS, user_rec.last_logged_in_ts,&lt;BR /&gt;                        user_ind.last_logged_in_ts_ind);&lt;BR /&gt;            user-&amp;gt;SetCreatedUserLoginId(VARCHAR_TO_STR(user_rec.created_user_login_id));&lt;BR /&gt;            user-&amp;gt;SetNotes(VARCHAR_TO_STR(user_rec.notes));&lt;BR /&gt;&lt;BR /&gt;            //----------------------------------------&lt;BR /&gt;            // Add fetched User to list&lt;BR /&gt;            //----------------------------------------&lt;BR /&gt;            collection.Add(user);&lt;BR /&gt;            user = NULL;&lt;BR /&gt;&lt;BR /&gt;        }&lt;BR /&gt;        EXEC SQL WHENEVER NOT FOUND CONTINUE;&lt;BR /&gt;&lt;BR /&gt;        EXEC SQL CLOSE :user_cv;&lt;BR /&gt;    }&lt;BR /&gt;    catch(...)&lt;BR /&gt;    {&lt;BR /&gt;        EXEC SQL CLOSE :user_cv;&lt;BR /&gt;        throw;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;}&lt;/DMOUSER&gt;</description>
    <pubDate>Wed, 30 Jul 2008 04:29:12 GMT</pubDate>
    <dc:creator>vj_agl</dc:creator>
    <dc:date>2008-07-30T04:29:12Z</dc:date>
    <item>
      <title>Please advise where is the memory leak in my pro*c</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/please-advise-where-is-the-memory-leak-in-my-pro-c/m-p/4242575#M677161</link>
      <description>void DBUser::LoadCollection(CollectionBase&lt;DMOUSER&gt;&amp;amp; collection)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;    EXEC SQL BEGIN DECLARE SECTION;&lt;BR /&gt;        struct sqlca sqlca;&lt;BR /&gt;    EXEC SQL END DECLARE SECTION;&lt;BR /&gt;&lt;BR /&gt;    memset(&amp;amp;sqlca, 0, sizeof(sqlca));&lt;BR /&gt;&lt;BR /&gt;    DmoUser *user = NULL;&lt;BR /&gt;&lt;BR /&gt;    //----------------------------------------------------&lt;BR /&gt;    // Thread Based Arrays to Support Multithreaded Mode&lt;BR /&gt;    //----------------------------------------------------&lt;BR /&gt;    EXEC SQL BEGIN DECLARE SECTION;&lt;BR /&gt;        struct UserRec *user_rec_ptr;&lt;BR /&gt;        struct UserInd *user_ind_ptr;&lt;BR /&gt;    EXEC SQL END DECLARE SECTION;&lt;BR /&gt;&lt;BR /&gt;    UserRec&amp;amp; user_rec = userRec[pthread_self()];&lt;BR /&gt;    user_rec_ptr = &amp;amp;user_rec;&lt;BR /&gt;&lt;BR /&gt;    UserInd&amp;amp; user_ind = userInd[pthread_self()];&lt;BR /&gt;    user_ind_ptr = &amp;amp;user_ind;&lt;BR /&gt;&lt;BR /&gt;    EXEC SQL WHENEVER SQLERROR DO SqlError( "DBUser::LoadCollection() error\n", sqlca);&lt;BR /&gt;&lt;BR /&gt;    //--------------------------&lt;BR /&gt;    // Get a SQL Context&lt;BR /&gt;    //--------------------------&lt;BR /&gt;    TRACELOG( TRACE_SYS_DB, "DBUser::LoadCollection Getting context");&lt;BR /&gt;    sql_context *ctx;&lt;BR /&gt;    ctx = DBMultiThreadSingleton::GetThreadContext();&lt;BR /&gt;    EXEC SQL CONTEXT USE :*ctx;&lt;BR /&gt;&lt;BR /&gt;    //--------------------------------------&lt;BR /&gt;    // Declare and allocate cursor variable.&lt;BR /&gt;    //--------------------------------------&lt;BR /&gt;    DBCursor dbCursor;&lt;BR /&gt;    EXEC SQL BEGIN DECLARE SECTION;&lt;BR /&gt;        SQL_CURSOR *user_cv = &amp;amp;dbCursor;&lt;BR /&gt;    EXEC SQL END DECLARE SECTION;&lt;BR /&gt;&lt;BR /&gt;    //---------------------------------&lt;BR /&gt;    // Open users cursor&lt;BR /&gt;    //---------------------------------&lt;BR /&gt;    EXEC SQL EXECUTE&lt;BR /&gt;    BEGIN&lt;BR /&gt;        users_pkg.get_users(:user_cv);&lt;BR /&gt;    END;&lt;BR /&gt;    END-EXEC;&lt;BR /&gt;&lt;BR /&gt;   //---------------------------------&lt;BR /&gt;    // Fetch and process user_cv rows&lt;BR /&gt;    // Close user_cv cursor&lt;BR /&gt;    //---------------------------------&lt;BR /&gt;    try&lt;BR /&gt;    {&lt;BR /&gt;        // Break when no more rows&lt;BR /&gt;        EXEC SQL WHENEVER NOT FOUND DO break;&lt;BR /&gt;&lt;BR /&gt;        for (;;)&lt;BR /&gt;        {&lt;BR /&gt;            EXEC SQL FETCH :user_cv&lt;BR /&gt;                INTO :user_rec_ptr INDICATOR :user_ind_ptr;&lt;BR /&gt;&lt;BR /&gt;            user = new DmoUser;&lt;BR /&gt;&lt;BR /&gt;            //----------------------&lt;BR /&gt;            // Populate data members&lt;BR /&gt;            //----------------------&lt;BR /&gt;            user-&amp;gt;SetUserID(user_rec.user_id);&lt;BR /&gt;            user-&amp;gt;SetLoginID(VARCHAR_TO_STR(user_rec.user_login_id));&lt;BR /&gt;            user-&amp;gt;SetSecurityProfilePk( IntVal(user_rec.security_profile_pk,&lt;BR /&gt;                                               user_ind.security_profile_pk_ind) );&lt;BR /&gt;            user-&amp;gt;SetUserName(VARCHAR_TO_STR(user_rec.user_name));&lt;BR /&gt;            user-&amp;gt;SetSPID(VARCHAR_TO_STR(user_rec.user_group));&lt;BR /&gt;&lt;BR /&gt;            StrToTime(user-&amp;gt;_userCreationTS, user_rec.user_creation_ts,&lt;BR /&gt;                        user_ind.user_creation_ts_ind);&lt;BR /&gt;            StrToTime(user-&amp;gt;_lastLoginTS, user_rec.last_logged_in_ts,&lt;BR /&gt;                        user_ind.last_logged_in_ts_ind);&lt;BR /&gt;            user-&amp;gt;SetCreatedUserLoginId(VARCHAR_TO_STR(user_rec.created_user_login_id));&lt;BR /&gt;            user-&amp;gt;SetNotes(VARCHAR_TO_STR(user_rec.notes));&lt;BR /&gt;&lt;BR /&gt;            //----------------------------------------&lt;BR /&gt;            // Add fetched User to list&lt;BR /&gt;            //----------------------------------------&lt;BR /&gt;            collection.Add(user);&lt;BR /&gt;            user = NULL;&lt;BR /&gt;&lt;BR /&gt;        }&lt;BR /&gt;        EXEC SQL WHENEVER NOT FOUND CONTINUE;&lt;BR /&gt;&lt;BR /&gt;        EXEC SQL CLOSE :user_cv;&lt;BR /&gt;    }&lt;BR /&gt;    catch(...)&lt;BR /&gt;    {&lt;BR /&gt;        EXEC SQL CLOSE :user_cv;&lt;BR /&gt;        throw;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;}&lt;/DMOUSER&gt;</description>
      <pubDate>Wed, 30 Jul 2008 04:29:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/please-advise-where-is-the-memory-leak-in-my-pro-c/m-p/4242575#M677161</guid>
      <dc:creator>vj_agl</dc:creator>
      <dc:date>2008-07-30T04:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: Please advise where is the memory leak in my pro*c</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/please-advise-where-is-the-memory-leak-in-my-pro-c/m-p/4242576#M677162</link>
      <description>There are no obvious C or C++ allocations.&lt;BR /&gt;You could use gdb's leak detection tools.</description>
      <pubDate>Wed, 30 Jul 2008 07:36:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/please-advise-where-is-the-memory-leak-in-my-pro-c/m-p/4242576#M677162</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-07-30T07:36:37Z</dc:date>
    </item>
    <item>
      <title>Re: Please advise where is the memory leak in my pro*c</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/please-advise-where-is-the-memory-leak-in-my-pro-c/m-p/4242577#M677163</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;Memory leak detector.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://www.hpux.ws/?p=8" target="_blank"&gt;http://www.hpux.ws/?p=8&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Wed, 30 Jul 2008 07:50:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/please-advise-where-is-the-memory-leak-in-my-pro-c/m-p/4242577#M677163</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2008-07-30T07:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Please advise where is the memory leak in my pro*c</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/please-advise-where-is-the-memory-leak-in-my-pro-c/m-p/4242578#M677164</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;In the try function or method you have an endless loop in wich you allocate memory ressource with the new operator :&lt;BR /&gt;&lt;BR /&gt;user = new DmoUser;&lt;BR /&gt;&lt;BR /&gt;You cannot release these ressource with an assign of NLL&lt;BR /&gt;&lt;BR /&gt;user = NULL;&lt;BR /&gt;&lt;BR /&gt;You hace to use de destructor delete instead ! So replace user = NULL by delete user !&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Roland&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 31 Jul 2008 13:08:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/please-advise-where-is-the-memory-leak-in-my-pro-c/m-p/4242578#M677164</guid>
      <dc:creator>Roland Piette</dc:creator>
      <dc:date>2008-07-31T13:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: Please advise where is the memory leak in my pro*c</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/please-advise-where-is-the-memory-leak-in-my-pro-c/m-p/4242579#M677165</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;Additionnal info :&lt;BR /&gt;&lt;BR /&gt;'new' and 'delete' are two operators used in C++ (object oriented program) to allocate objects in the heap memory. So when you create an instance with 'new' operator an amount of memory is reserve for the object. When you assign a NULL to this pointer (user variable) the previous allocated object can any more be released. This part of memory is hold by the process and will be released when it finishes or crashes. So to release the object you have to use the 'delete' operator !&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Roland</description>
      <pubDate>Thu, 31 Jul 2008 13:17:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/please-advise-where-is-the-memory-leak-in-my-pro-c/m-p/4242579#M677165</guid>
      <dc:creator>Roland Piette</dc:creator>
      <dc:date>2008-07-31T13:17:21Z</dc:date>
    </item>
  </channel>
</rss>

