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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:55:39+00:00 2026-05-24T09:55:39+00:00

Is dividing the work into 5 functions as opposed to one big function more

  • 0

Is dividing the work into 5 functions as opposed to one big function more memory efficient in C since at a given time there are fewer variables in memory, as the stack-frame gets deallocated more often?

Answer given there are a lot of local variables and the stack frames comes from a centralized main and not created on the top of each other.

I know other advantages of breaking out the function into smaller functions. Please answer this question, only in respect to memory usage.

  • 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-24T09:55:40+00:00Added an answer on May 24, 2026 at 9:55 am

    It’s very language and compiler dependent.
    For languages like Python where variables can be accessed dynamically (eg globals()['x']), you’re effectively reducing the time for which each variable is in an accessible scope, allowing the memory to be reclaimed more often. Depending on how you do it, you may be forcing the interpreter to hold on to more scopes, and the scopes themselves can potentially use extra memory. Eg, if you’re taking a chunk out of f1 and making it f2 which gets called from f1, you’re increasing the stack depth & the number of scopes that have to be held onto.

    For compiled languages with mature compilers like C, the memory for variables is often only used for as long as they are actually needed. So you won’t be able to do much that the compiler doesn’t already do.

    Keep in mind that when you call a function, local variables need to be moved from registers onto the stack, as well as a return address. So in some cases, you’ll end up with a bigger memory footprint if you break it apart into multiple functions called from within the original.
    But also realize that if a function is only called from one place, there’s a good chance that your compiler will inline it.

    So in summary, it’s hard to predict, and will make very little difference. Just do what is most readable.

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

Sidebar

Related Questions

A long time ago, when my company was much smaller, dividing the development work
How do you go about dividing the views into smaller views. Let's say I
What should be the general guidelines/gotchas for dividing application code (App_Code) into separate files?
Can anyone speak to the ease of dividing work amongst multiple developers when designing
Is there a faster way of dividing by 2, with sign, in assembly than
In our SaaS system we're dividing users into separate pools according to the customer
I am dividing two int values, and im expecting to get a double one.
I having trouble in dividing the HTML frames. I have been using the following
In the sample code below I am dividing by zero which when I step
I just started programming in C# and was reading about dividing your application /

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.