Re: No need to optimize in assembly anymore

From: Bryan Parkoff (bryan.nospam.parkoff_at_nospam.com)
Date: 05/23/04


Date: Sun, 23 May 2004 02:10:12 +0000 (UTC)

Matt,

    Okay, do you claim that variables and functions inside classes are
better than container classes and STL? You would want to avoid malloc or
new function if it is less than 1MB. It is not really necessary to use
malloc or new functions if memory is not very big.
    What is the minimum MB that malloc or new function should be used? I
suspect 10MB.?????
    Is it true that malloc or new function is never used if segments are
used instead of flat model under 640KB? It sounds like malloc or new
function uses to allocate virtual memory, but below 640KB does not. Correct
me if I am wrong.

-- 
Bryan Parkoff
"Matt Taylor" <para@tampabay.rr.com> wrote in message
news:_KRrc.19466$Ol3.15521@twister.tampabay.rr.com...
> "Bryan Parkoff" <bryan.nospam.parkoff@nospam.com> wrote in message
> news:H%prc.9302$Hh.4606@fe1.texas.rr.com...
> > Matt,
> >
> >     I don't understand your point.  You state that container classes or
> just
> > classes are slower than structs.  If it is true that many assembler
> > programmers and C (not C++) programmers are sticking with structs
because
> > they think that it can increase the performance better than classes.  Is
> it
> > true?
> <snip>
>
> I am criticizing the *universal* use of container classes. I am saying
that
> std::vector is acceptable in some cases, but in other cases it is better
to
> create an array of 5 elements on the stack. (Aside: the one thing I do
> dislike about STL containers is that they use C++ exception handling. With
> MSVC, this results in bloated code.)
>
> It is like the example I gave:
>
> // ...
> char *buf = new char[256];
> FILE *fp;
> sprintf(buf, "%s%s", path, filename);
> fp = fopen(buf, "rb");
> delete[] buf;
> // ...
>
> This code could be rewritten like this:
> // ...
> char buf[256];
> FILE *fp;
> sprintf(buf, "%s%s", path, filename);
> fp = fopen(buf, "rb");
> // ...
>
> Fast code should avoid malloc & new whenever possible.
>
> -Matt
>


Relevant Pages

  • Re: No need to optimize in assembly anymore
    ... better than container classes and STL? ... malloc or new functions if memory is not very big. ... > dislike about STL containers is that they use C++ exception handling. ... > Fast code should avoid malloc & new whenever possible. ...
    (alt.lang.asm)
  • Re: GC in Jons raytracing benchmark
    ... Using new and delete with reference counting, ... > The simplest way to address this issue is to switch to C++ and use STL ... > containers instead of malloc and free. ... > and play around with multiple allocators or adaptive allocation and so on. ...
    (comp.lang.lisp)
  • Re: Avoiding malloc
    ... For a resource constrained embedded system I want to avoid malloc. ... you could provide your own malloc with less storage overhead - ...
    (comp.lang.c)
  • Re: Strange linker errors (LNK2005) in Release build only .... why ??
    ... This is what I've resorted to now - the only downside being that all the ... new calls in STL which land up using malloc will no longer be using ... I'd rather not re-direct all STL containers by writing my own ...
    (microsoft.public.vc.stl)