Click here to Skip to main content
13,052,669 members (63,388 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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...);

Now if I run
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 5:50am
Updated 26-Dec-11 13:09pm
SAKryukov 25-Dec-11 15:11pm
Not enough information.

1 solution

Rate this: bad
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.
SAKryukov 25-Dec-11 15:10pm
Very reasonable advice, a 5.
HvdBrand 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 26 Dec 2011
Copyright © CodeProject, 1999-2017
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