Bug 65413

Summary: kstars is a memory hog
Product: [Applications] kstars Reporter: Rolf Offermanns <rolf.offermanns>
Component: generalAssignee: kstars
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: fix for some memory leakage

Description Rolf Offermanns 2003-10-03 12:58:40 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc version 3.3.1 
OS:          Linux

I read about kstars in a recent article on the "dot". I run gentoo so I tried the kde-cvs kdeedu ebuild, which builds kde from HEAD cvs. I started kstars about 13 hours ago and forgot to close it. After that time it had aquired about 350MB of RAM. Something is wrong here! :)
Let me know if I can do something to help resolve this bug.
Comment 1 kstars 2003-10-03 16:37:55 UTC
Thank you very much for the report.  I have confirmed that memory usage increases 
while KStars is running.  Looks like we've got a leak.  I really appreciate your 
bringing this to our attention.  If you have experience with kcachegrind, you could 
help us try to track it down, if you want.  Otherwise, watch this space for updates. 
 
thanks again, 
Jason 
 
Comment 2 Rolf Offermanns 2003-10-03 17:19:02 UTC
Created attachment 2678 [details]
fix for some memory leakage

I don't have experience with kcachegrind. However, I wanted to try it for some
time, so why not now! :)
I run valgrind on kstars (which is unfortunately nearly to much for my system),
and it showed two places of potential memory leaks. Please see the attached
patch, I don't know if this is the right place to fix it, but it seems OK for
me.
Comment 3 kstars 2003-10-03 17:51:33 UTC
Subject: kdeedu/kstars/kstars

CVS commit by harris: 

Fixed bug #65413, regarding memory leaks.  The reporter not only let us 
know about the problem, but also diagnosed it with valgrind, and kindly 
provided a patch that fixed four memory leaks.  Each case was a missing 
'delete' command when 'new' had been called.  Thanks for the help, Rolf!

CCMAIL: 65413-done@bugs.kde.org
CCMAIL: kstars-devel@kde.org
  


  M +11 -6     kstarsdata.cpp   1.98
  M +2 -0      ksutils.cpp   1.16


--- kdeedu/kstars/kstars/kstarsdata.cpp  #1.97:1.98
@@ -325,6 +325,8 @@ while ( (c = (char) file.getch()) != -1)
       // Get host name
       ap = findXMLAtt(root, "name");
-      if (!ap)
+      if (!ap) {
+        delLilXML(xmlParser);
        return false;
+      }
 
        INDIHostsInfo *VInfo = new INDIHostsInfo;
@@ -335,7 +337,8 @@ while ( (c = (char) file.getch()) != -1)
       ap = findXMLAtt(root, "hostname");
 
-      if (!ap)
+      if (!ap) {
+        delLilXML(xmlParser);
        return false;
-
+      }
 
     VInfo->hostname = QString(ap->valu);
@@ -343,6 +346,8 @@ while ( (c = (char) file.getch()) != -1)
     ap = findXMLAtt(root, "port");
 
-     if (!ap)
+    if (!ap) {
+      delLilXML(xmlParser);
       return false;
+    }
 
     VInfo->portnumber = QString(ap->valu);

--- kdeedu/kstars/kstars/ksutils.cpp  #1.15:1.16
@@ -180,4 +180,6 @@ dms KSUtils::GSTat0hUT( const QDateTime 
         gst.setH( t1 );
 
+        delete num;
+
         return gst.reduce();
 }