Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

tehmagik Group Title

If, in c++, I were to create a large number of very large arrays and never delete them with the delete [] command (but be sure of no memory leaks), would there be any negative consequences? That is, would I possibly run out of memory on the stack and get segfaults if I were to continue making huge arrays? Thanks!

  • 2 years ago
  • 2 years ago

  • This Question is Closed
  1. osanseviero Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    I think you would...and it would become really slow...but that depends on how big the arrays are

    • 2 years ago
  2. jjustinb Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    don't think as much about the entire machine as the processor. When a class, it's data, and the current function of operation fit within the CPU cache, you have an automatic boost in speed. When you allocate large numbers of large arrays, all memory is accessed externally to the CPU instruction and memory caches. This may be necessary if you are multithreaded anyhow, but if your intent is speed you want small useable chunks rather than big allocations. One other issue is that when you reach the 2gig boundary of a 32bit program, or the 4gig boundary of a 32bit program run in a 64bit window, you risk a crash of the software (segfault). Prior to this limit, you always risk being cached to disk to allow other software to run on the host machine. Smaller means less caches to disk (virtual memory) and faster operation.

    • 2 years ago
  3. stormfire1 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Nice answer...me likey.

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.