473,324 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

correct approach to fix a bug

bob
Hi,

We are having a resource issue with our legacy codebase that involves
use of semaphores (in summary we use custom containers in an abstract
base class. Each uses 2 semaphores which causes lots of handles to be
consumed on windoze). when the application is under heavy load, we have
a lot of these containers, and thus semaphores being instantiated.
Eventually Bill Gates bombs out when no more handles are available. God
bless his soul.
Looking at the code, we see that the containers are instantiated in an
abstract base class. The obvious thing to do in this case is to move
the containers down into the non-abstract classes so we reduce the
number of times a container is instantiated (not all derived classes
need the containers and thus the semaphores) and so we'll save on the
number of semaphores consumed by the OS.

I'd like to know if there's a known c++ design approach that can be
adopted in this case. Is there any technique or strategy that is known
and can be generally applied in this kind of scenario. Its the design
rather than the detail (obviously, as I've given no detail :) ) that
interests me in this case.
Hope I've posted enough info. If not I'll add as needed.

have a nice day.

grahamO

May 10 '06 #1
2 1410

"bo*@blah.com" <Gr**********@gmail.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
Hi,

We are having a resource issue with our legacy codebase that involves
use of semaphores (in summary we use custom containers in an abstract
base class. Each uses 2 semaphores which causes lots of handles to be
consumed on windoze). when the application is under heavy load, we have
a lot of these containers, and thus semaphores being instantiated.
Eventually Bill Gates bombs out when no more handles are available. God
bless his soul.
Looking at the code, we see that the containers are instantiated in an
abstract base class. The obvious thing to do in this case is to move
the containers down into the non-abstract classes so we reduce the
number of times a container is instantiated (not all derived classes
need the containers and thus the semaphores) and so we'll save on the
number of semaphores consumed by the OS.

I'd like to know if there's a known c++ design approach that can be
adopted in this case. Is there any technique or strategy that is known
and can be generally applied in this kind of scenario. Its the design
rather than the detail (obviously, as I've given no detail :) ) that
interests me in this case.
Hope I've posted enough info. If not I'll add as needed.

have a nice day.

grahamO


Can you send a small piece of code that shows how you are writing. I am not
sure,but it seems too many values are copied to memory. The way around that
is references and pointers. This is C++?

Jeff
May 10 '06 #2
bo*@blah.com wrote:
Hi,

We are having a resource issue with our legacy codebase that involves
use of semaphores (in summary we use custom containers in an abstract
base class. Each uses 2 semaphores which causes lots of handles to be
consumed on windoze). when the application is under heavy load, we have
a lot of these containers, and thus semaphores being instantiated.
Eventually Bill Gates bombs out when no more handles are available. God
bless his soul.
Looking at the code, we see that the containers are instantiated in an
abstract base class. The obvious thing to do in this case is to move
the containers down into the non-abstract classes so we reduce the
number of times a container is instantiated (not all derived classes
need the containers and thus the semaphores) and so we'll save on the
number of semaphores consumed by the OS.

I'd like to know if there's a known c++ design approach that can be
adopted in this case. Is there any technique or strategy that is known
and can be generally applied in this kind of scenario. Its the design
rather than the detail (obviously, as I've given no detail :) ) that
interests me in this case.
Hope I've posted enough info. If not I'll add as needed.

have a nice day.

grahamO


Off the top of my head within the level of detail you've given, I'd say
you might create a second ABC that has the shared data, and have those
classes that need it inherit from the second ABC and those that don't
from the first. Something like:

class Base
{
public:
virtual void Foo() = 0; // interface
};

class BaseWithSharedData : public Base
{
public:
// ... doesn't implement Foo()
private:
Semaphore sem_;
std::vector<int> data_;
};

class DerivedWithoutData : public Base
{
public:
virtual void Foo() { /*...*/ }
};

class DerivedWithData : public BaseWithSharedData
{
public:
virtual void Foo() { /*...*/ }
};

Cheers! --M

May 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: David Opstad | last post by:
I have a question about text rendering I'm hoping someone here can answer. Is there a way of doing linguistically correct rendering of Unicode strings in Python? In simple cases like Latin or...
1
by: Craig Ringer | last post by:
Hi folks I'm a bit of a newbie here, though I've tried to appropriately research this issue before posting. I've found a lot of questions, a few answers that don't really answer quite what I'm...
0
by: Alf P. Steinbach | last post by:
The seventh part of my attempted Correct C++ tutorial is now available, although for now only in Word format (use free Open Office if no Word), and also, it's not yet been reviewed at all -- ...
2
by: Jim | last post by:
I'm writing an Invoicing Windows app but I'm writing it to make the code as easy to maintain as possible. Basically, to get any records from my DB, I use two classes: one that sets up the SQL...
9
by: Jon Rea | last post by:
I hav been looking for the last 2 hours on how to do this without much luck. Im going to give a simplifed model of the problem i have. I want a collection class that can holds a series or...
4
by: metaperl | last post by:
I work at a place which is currently running SQL 2000, but they are planning to migrate to 2k5. I was thinking that this is the perfect opportunity to fix all the weaknesses we have had in our data...
0
by: craigkenisston | last post by:
I have a form with a repeater that is filled from a BLL object, and a dropdownlist. The dropdownlist has a parameters that is used in the BLL class, the number of rows about to be displayed. I...
23
by: Anders Borum | last post by:
Hi! I am implementing a threaded producer / consumer pattern just for fun. I am using an internal counter to keep track of the produced / consumed items and am logging that information. I am...
4
by: Polaris431 | last post by:
I have a web application in ASP.NET that will be used globally. Data is collected on mobile devices running Windows Mobile and sent to the web server where it is stored and can be viewed. Data is...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.