Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>If I am not using "new" and "delete", and all of my variables are being initialized INSIDE of local functions, is it possible to have memory leaks / allocation problems through repeated function calls?</p> </blockquote> <p>Unclear. If all the variables you refer to are local, no. If you're using malloc(), calloc(), and free(), yes.</p> <blockquote> <p>Is there any chance I am running low on stack memory, if I am doing the whole program through the stack?</p> </blockquote> <p>Not if you get bad_alloc. If you got a 'stack overflow' error, yes.</p> <blockquote> <p>Is it possible I need to load some of my big lookup tables (maps, etc.) on the heap and then just use the stack for my iterations where speed is important?</p> </blockquote> <p>Well, it's hard to believe that you need a local copy of a lookup table in every stack frame of a recursive method.</p> <blockquote> <p>Is there a problem with using resize a lot related to memory?</p> </blockquote> <p>Of course. You can run out.</p> <blockquote> <p>Could this be an instance where I should use "new" and "delete"</p> </blockquote> <p>Impossible today without knowing more about your data structures.</p> <blockquote> <p>(I've been warned in many instances not to use those unless there is a very strong, specific reason to do so)?</p> </blockquote> <p>By whom? Why?</p> <blockquote> <p>Within the problem function, I am creating a class variable,</p> </blockquote> <p>You are creating an instance of the class on the stack. I think. Please clarify.</p> <blockquote> <p>then writing over that variable about 20 times (once for each "iteration" of my model).</p> </blockquote> <p>With an assignment? Does the class have an assignment operator? Is it correct? Does the class itself use heap memory? Is it correctly allocated and deleted on construction, destruction, and assignment?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload