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 3211088
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:41:13+00:00 2026-05-17T14:41:13+00:00

Is it advisable to create your own Activity stack (which contains only the activity

  • 0

Is it advisable to create your own Activity stack (which contains only the activity names rather then the complete activity as in the default stack) to improve the memory consumption of the application.

What im basically doing is maintaining a string stack containing the activity names and override the back button functionality to launch Intent with the stack top and finish the current activity. I also add a parameter to decide if the current activity should go into the stack or not (useful in certain situation). So basically I do a startActivity every time I have to launch a new activity and finish the current one so that there is nothing in the default stack and on back press also start the activity from my stack and finish the current activity.

Ques 1: Is it advisable to do it this way? What are the possible problems that could happen?

Ques 2: Can someone give me an idea of the memory usage of the default Android activity stack so that I can compare it with my own implementation?

  • 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-17T14:41:14+00:00Added an answer on May 17, 2026 at 2:41 pm

    Is it advisable to create your own Activity stack (which contains only the activity names rather then the complete activity as in the default stack) to improve the memory consumption of the application.

    Generally no, no more than a Web app typically hacks into the browser to change the browser history and delete items out of the browser cache.

    What are the possible problems that could happen?

    You lose your state on every operation. Normally, the BACK button takes the user back to the previous activity, with its state intact. There’s even a framework for maintaining this state (onSaveInstanceState()) if Android elects to close up an activity to free up memory.

    You also force more garbage collection than is necessary, by finishing activities that the user is not yet done with and forcing their re-creation, which wastes CPU time and battery life.

    I have some nagging concerns about the impacts of your strategy on configuration changes (e.g., rotation, dock), but I can’t put my finger on any specifics.

    Can someone give me an idea of the memory usage of the default Android activity stack so that I can compare it with my own implementation?

    You are asking the wrong question. The question you should be asking is: What is the evidence that there is a problem in the first place?

    It is entirely possible that there is something rather unusual about your application that makes your strategy a sound one (e.g., lots of memory-intensive bitmaps). However, in general, unless there is a demonstrable problem, things like what you are doing fall under the heading of “premature optimization”. Even then, there may be better solutions to whatever the actual problem is…but you won’t know that unless and until you determine there is, indeed, a problem.

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

Sidebar

Related Questions

I am attempting to create a UIView (and associated UIViewController ) which mimic the
It is advisable to use tables in HTML pages (now that we have CSS)?
Is it advisable to use arrays in Javascript using tens of thousands of indexes?
Why is it not advisable to use JavaScript in JSP? One rationale that I
I'm just learning Perl. When is it advisable to use OO Perl instead of
I've been using AppFuse to create my projects for a while now. And I'm
When dealing with any framework with which you are not 100% familiar, I've found
When we create a DLL using Visual studio (VC8 or 9), we get an
Is there some kind of Session size limitation or advisable value to not to
I've got a web site that contains a set of effectively independent tools with

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.