Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1003005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:54:44+00:00 2026-05-16T07:54:44+00:00

Our server recently has been going down a lot and I was tasked to

  • 0

Our server recently has been going down a lot and I was tasked to improve the memory usage of a set of classes that was identified to be the culprit.

I have code which initializes an instance of an object and goes like this:

boolean var1;
boolean var2;
.
.
.
boolean var100;

void setup() {
 var1 = map.hasFlag("var1");
 var2 = map.hasFlag("var2);
 .
 .
 .
 if (map.hasFlag("some flag") {
     doSomething();
 }
 if (var1) {
   increment something
 }
 if (var2) {
   increment something
 }

}

The setup code takes about 1300 lines. My question is if it is possible for this method to be more efficient in terms of using too many instance variables.

The instance variables by the way are used in a “main” method handleRow() where for example:

handleRow(){
   if (var1) {
     doSomething();
   }
   .
   .
   . 
   if (var100) {
     doSomething();
    }
}

One solution I am thinking is to change the implementation by removing the instance variables in the setup method and just calling it directly from the map when I need it:

handleRow(){
  if (map.hasFlag("var1") {
      doSomething();
  }
  .
  .
  . 
  if (map.hasFlag("var100") {
     doSomething();
  }
}

That’s one solution I am considering but I would like to hear the inputs of the community. 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:54:45+00:00Added an answer on May 16, 2026 at 7:54 am

    100 boolean variables will take 1.6k of memory when every boolean with overhead takes 16 bytes (which is a bit much imho) I do not think this will be the source of the problem.

    Replacing these flags with calls into the map will negatively impact performance, so your change will probably make things worse.

    Before you go redesigning your code (a command pattern looks like a good candidate) you should look further into where the memory leak is that you are asked to solve.

    Look for maps that the classes keep adding to, collections that are static variables etc. Once you find out where the reason for the memory growth lies you can decide which part of your classes to refactor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently our Subversion (SVN) server was changed and we did a svn switch .
I recently bought a new web server 2008 for our company and require a
Recently, I started changing some of our applications to support MS SQL Server as
Our server already has symantic anti-virus with autoprotect enabled w/ regular scans and updates.
If our server (running on a device) starts before a DHCP lease had been
Our Tfs server (Tfs2008) has smtp server installed. But we could not make Tfs
We use BigIP to load balance between our two IIS servers. We recently deployed
Our server application is listening on a port, and after a period of time
I package our server releases into zip files using a batch file (Windows), running
I'm creating an ASP.NET web application to schedule tasks on our server from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.