- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Please advise where is the memory leak in my p...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2008 09:29 PM
тАО07-29-2008 09:29 PM
Please advise where is the memory leak in my pro*c
{
EXEC SQL BEGIN DECLARE SECTION;
struct sqlca sqlca;
EXEC SQL END DECLARE SECTION;
memset(&sqlca, 0, sizeof(sqlca));
DmoUser *user = NULL;
//----------------------------------------------------
// Thread Based Arrays to Support Multithreaded Mode
//----------------------------------------------------
EXEC SQL BEGIN DECLARE SECTION;
struct UserRec *user_rec_ptr;
struct UserInd *user_ind_ptr;
EXEC SQL END DECLARE SECTION;
UserRec& user_rec = userRec[pthread_self()];
user_rec_ptr = &user_rec;
UserInd& user_ind = userInd[pthread_self()];
user_ind_ptr = &user_ind;
EXEC SQL WHENEVER SQLERROR DO SqlError( "DBUser::LoadCollection() error\n", sqlca);
//--------------------------
// Get a SQL Context
//--------------------------
TRACELOG( TRACE_SYS_DB, "DBUser::LoadCollection Getting context");
sql_context *ctx;
ctx = DBMultiThreadSingleton::GetThreadContext();
EXEC SQL CONTEXT USE :*ctx;
//--------------------------------------
// Declare and allocate cursor variable.
//--------------------------------------
DBCursor dbCursor;
EXEC SQL BEGIN DECLARE SECTION;
SQL_CURSOR *user_cv = &dbCursor;
EXEC SQL END DECLARE SECTION;
//---------------------------------
// Open users cursor
//---------------------------------
EXEC SQL EXECUTE
BEGIN
users_pkg.get_users(:user_cv);
END;
END-EXEC;
//---------------------------------
// Fetch and process user_cv rows
// Close user_cv cursor
//---------------------------------
try
{
// Break when no more rows
EXEC SQL WHENEVER NOT FOUND DO break;
for (;;)
{
EXEC SQL FETCH :user_cv
INTO :user_rec_ptr INDICATOR :user_ind_ptr;
user = new DmoUser;
//----------------------
// Populate data members
//----------------------
user->SetUserID(user_rec.user_id);
user->SetLoginID(VARCHAR_TO_STR(user_rec.user_login_id));
user->SetSecurityProfilePk( IntVal(user_rec.security_profile_pk,
user_ind.security_profile_pk_ind) );
user->SetUserName(VARCHAR_TO_STR(user_rec.user_name));
user->SetSPID(VARCHAR_TO_STR(user_rec.user_group));
StrToTime(user->_userCreationTS, user_rec.user_creation_ts,
user_ind.user_creation_ts_ind);
StrToTime(user->_lastLoginTS, user_rec.last_logged_in_ts,
user_ind.last_logged_in_ts_ind);
user->SetCreatedUserLoginId(VARCHAR_TO_STR(user_rec.created_user_login_id));
user->SetNotes(VARCHAR_TO_STR(user_rec.notes));
//----------------------------------------
// Add fetched User to list
//----------------------------------------
collection.Add(user);
user = NULL;
}
EXEC SQL WHENEVER NOT FOUND CONTINUE;
EXEC SQL CLOSE :user_cv;
}
catch(...)
{
EXEC SQL CLOSE :user_cv;
throw;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2008 12:36 AM
тАО07-30-2008 12:36 AM
Re: Please advise where is the memory leak in my pro*c
You could use gdb's leak detection tools.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-30-2008 12:50 AM
тАО07-30-2008 12:50 AM
Re: Please advise where is the memory leak in my pro*c
Memory leak detector.
http://www.hpux.ws/?p=8
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 06:08 AM
тАО07-31-2008 06:08 AM
Re: Please advise where is the memory leak in my pro*c
In the try function or method you have an endless loop in wich you allocate memory ressource with the new operator :
user = new DmoUser;
You cannot release these ressource with an assign of NLL
user = NULL;
You hace to use de destructor delete instead ! So replace user = NULL by delete user !
Regards,
Roland
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2008 06:17 AM
тАО07-31-2008 06:17 AM
Re: Please advise where is the memory leak in my pro*c
Additionnal info :
'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 !
Regards,
Roland