LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-04-2003, 10:38 PM   #1
bektas
LQ Newbie
 
Registered: Aug 2003
Posts: 2

Rep: Reputation: 0
top utility and performance


Folks,

I have written an application using gcc-3.2.2.
It uses lots of arrays with reasonable large sizes(10-4096) for different "structure"s and ncurses. It also has 9-threads running in an infinite loop.

After I run my program, I open another shell and run "top" and check the numbers. The load avreage is just fine, near 0.0 most of the time. However, RSS and SIZE values are keep increasing every 10seconds or so. Say, they starts from 3MB, then becomes 12MB in 10 seconds, or become 201M in 6 hours at the same situation(idle) of the program. I don't do anything further or open any drop-down windows in the program. Just sits and runs in the memory.

I use kernel 2.4 on an P200 PC.

Can someone give me a hand to cause of the increasing memory usage, please?

Appreciate it.
 
Old 08-04-2003, 10:47 PM   #2
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
Most likely there is memory leakage in your program.
You keep creating objects without releasing old ones.
Keep track of the un-destroyed un-referenced objects in your program.
 
Old 08-05-2003, 03:33 PM   #3
bektas
LQ Newbie
 
Registered: Aug 2003
Posts: 2

Original Poster
Rep: Reputation: 0
You are are right. That was the case. It has a thread running in an indefinite loop, which calls mysql routines below.

//program starts
..
MYSQL *mysqlconnect(void) {
const char *s;
MYSQL *mysql;

if((mysql=mysql_init(NULL))==NULL) return NULL;
if((mysql_real_connect(mysql, DBHOST, DBUSER, DBPW, DBDB, 0, NULL, 0))==NULL) {
s=mysql_error(mysql);
report(SYSLOG, (char *) s, error_code_predescribed);
mysql_close(mysql);
return NULL;
}
else return (mysql);
}
..

//thread procedure starts
MYSQL mysql;
..
while(1) {
if((mysql=mysqlconnect)!=NULL) {
do some database operations;
}
else sleep(5);
} //while
..
//thread ends


Main {
..
}
//program ends

Because mysql pointer never gets freed it always creates a new one for each loop in thread procedure.
I copied mysqlconnect procedure content into the thread, and localize it. Then, it solved the problem.
However, I need to search some other solutions. Because I call mysqconnect almost in every procedure.

Thank you so much for your great advise.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
top utility source code puishor Programming 5 10-09-2015 01:55 AM
kde performance utility tompouceuh SUSE / openSUSE 1 10-07-2005 03:42 PM
"multiboot utility" and "dell utility partition" on dell i5150 xround Linux - Laptop and Netbook 5 04-21-2005 09:19 AM
'Top' utility floating point error Ealric Linux - Software 4 07-24-2003 06:18 AM
Graphical Utility to Monitor System Performance DavidMD Linux - Software 5 06-10-2003 09:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration