Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
Hi all,
 
I'm working on a program to do multiple Simulations and determine the optimal settings, related to measured data.
I use the gtkmm toolkit for a GUI and glibmm for multithread support.
 
For this purpose I have a an object named SimulationCCD.
I initialize this object and run it using run_simulation(), like this:
void run_sims()
{
    for (unsigned i=0;i<10000;i++)
    {
        SimulationCCD simccd(...some parameters here...);
        simccd.run_simulation();
    }
}
 
Now if I run
run_sims()
memory usage is low as expected: The SimulationCCD object is destructed after every single run.
A completely different thing happens if I run the function in a thread like this
     Glib::Thread* m_sim_thread=Glib::Thread::create(sigc::mem_fun(*this, &Regression::run_sims), true);
This code results in increased memory usage. In this case it looks like the SimulationCCD objects are not destroyed.
The memory usage of the program just increases unchecked.
 
Has anyone experienced this problem using glibbm threads and are there any known solutions? (preferably using the glibmm or glib toolkit)
 
Best wishes,
Hugo van den Brand
Posted 25-Dec-11 6:50am
Edited 26-Dec-11 14:09pm
v2
Comments
SAKryukov at 25-Dec-11 15:11pm
   
Not enough information.
--SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

We have no hope of helping you based on the provided code snippet. My advice is to create just 1 simulation, and put a breakpoint in each destructor to make sure what you think is happening, is in fact happening.
 
If you can determine how much memory is remaining allocated, you can probably determine which object isn't being deleted. If you're creating threads or using bitmaps, it could be that you're not properly freeing the resources.
 
It could quite literally be anything.
  Permalink  
Comments
SAKryukov at 25-Dec-11 15:10pm
   
Very reasonable advice, a 5.
--SA
HvdBrand at 26-Dec-11 18:55pm
   
Thanks John, you're right, based on what I posted it could have been almost anything. I've made a minimal testcase and found out some interesting specifics listed as an improvement to my question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 485
1 BillWoodruff 330
2 OriginalGriff 310
3 Shweta N Mishra 244
4 Mathew Soji 225
0 OriginalGriff 6,153
1 Sergey Alexandrovich Kryukov 5,638
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,710


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 26 Dec 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100