Re: Cannot use DEBUG_NEW to trace this leak.

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



36MB is not particularly large. Why do you have to read all the lines in anyway? If
you're concerned about space, line-at-a-time is slower but uses less memory.

Key here is MEASURING speed. You identify "hot spots" and fix THOSE, you don't decide a
priori and in the absence of any substantiating data that the cost of the array is the
important parameter. And if it is, you look at std::vector, and apply
std::vector::reserve if necessary, before dropping down to low-level coding.
joe

On Thu, 24 Jan 2008 22:43:02 +0200, "Simon" <spambucket@xxxxxxxxxxx> wrote:


I think that STL containers are fast enough.

This is the problem, as it is now, (with the std::vector), the code is very
fast.
So coming up with an even faster design is hard to judge.


6 MB is not big memory allocation for today standards :)

So, you can alloc this memory block using 'new char[MAX_CHARS*MAX_LINE]',
and manage it yourself with pointers and pointers arithmetic.


Well, my file is over 36Mb, (including spaces and so forth).
And I am manipulating each lines of data to fill various string/int/float
arrays so the final size of my vector should be a lot less than 36Mb.
This is why it is a bit hard to simply read one line and place it in the
array.

I will play around with pointers, but I am not sure they will buy me more
time, (but maybe more memory).

Thanks for the info

Simon
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Dusty Deck and C memory manager, Part 1
    ... CMEMC.C -- C memory management routines for use with FORTRAN. ... Return an index into ARRAY representing LENGTH words of available ... void *ptr, *malloc; ... Rather than introduce Cray pointers and use C routines to allocate memory for Fortran arrays, you could use straight F90, for example: ...
    (comp.lang.fortran)
  • Re: Simple C containers, std::vector analog
    ... You're right about not needing to care very much about the memory ... blocks, in not knowing the ultimate size of the growable array, because ... there is no realloc function, and besides realloc might be having ... whether it's used for the list of array block pointers only or a C++ ...
    (comp.lang.c)
  • Re: Differance between Array and Pointers
    ... Well, except that arrays tend to be much larger than pointers, and the ... An array is a contiguous region of memory containing N elements of M ... indexing vs. a loop). ...
    (comp.arch.embedded)
  • Re: far pointer
    ... has nothing to do with comparing pointers for equality. ... > array y is probably next to array x in memory. ... and doesn't require segmented memory. ...
    (comp.lang.c)
  • Re: far pointer
    ... The restriction that pointers must be calculated within the object, has nothing to do with comparing pointers for equality. ... array y is probably next to array x in memory. ... and doesn't require segmented memory. ...
    (comp.lang.c)