Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

tehmagik

  • 3 years ago

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!

  • This Question is Closed
  1. osanseviero
    • 3 years ago
    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. jjustinb
    • 3 years ago
    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.

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

    Nice answer...me likey.

  4. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

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.