Re: prefast "stack hog" warning for new'ed array

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Tom Moon wrote:
> (Also posted to microsoft.public.windowsce)

Don't multipost. Rather cross-post and set a suitable follow-up.

> warning 262: This function uses 20232 bytes of stack:
> exceeds /StackHogThreshold=16384. Consider moving some data to heap.

> Does not new allocate memory from the heap? If new allocated memory on
> the stack then wouldn't a new'd object be lost when the function
> returns thus subverting new's purpose ?

You are right, new allocates from the heap and this warning is bogus. Well,
assuming the implementation doesn't do anything fancy.

Other than that, does anyone here know of a fix for the broken new which
doesn't throw when it runs out of memory? Preferably for both VC6 and eVC4.

Uli


.



Relevant Pages

  • Re: Heap and stack size?
    ... > i want to write a c program to find the heap size, stack size. ... hs.c:7: warning: initialization makes pointer from integer without a cast ... hs.c:15: warning: initialization makes pointer from integer without a cast ...
    (comp.unix.programmer)
  • Re: C++ Question
    ... (ImageConsultant) ... > Q 1 Write a class which always allocate memory to its objects from heap only? ... If you feel the class has too big a sizeofto put on the stack then ...
    (comp.lang.cpp)
  • Re: stack questions
    ... platform specific caveat to this since the documentation does not suggest ... Unless you are overflowing the stack, ... allocate memory outside the stack space? ... Yes, malloc allocates memory on the heap, not the stack (this is exactly how ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: How does managed code work?
    ... Does it work the same way as the native stack with a frame pointer that is the head of a linked list of stack frames where each time we enter a function we create a new stack frame in which new variables are pushed and each time we exit a function the entire stack frame is popped? ... Can someone point me to a discussion of the managed heap? ... How does it prevent memory leaks that occur in COM when two objects reference each other and keep the others reference count nonzero? ... Because objects don't go out of scope, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Groovy (war Re: [PROST]Re: CDC Plugin fuer Eclipse)
    ... Warum müsste man continuations erlauben Stackvariablen in den Heap zu verschieben? ... Ein activation record speichert die Parameter und lokalen Variablen der Funktion und eine Information, ... Da diese activation records klassischerweise auf einem Stack verwaltet werden, kann man hier Stackspace sparen - Endrekursion ist damit genauso effizient wie eine klassische Iteration mit einem Sprung. ...
    (de.comp.lang.java)