On Friday, 14 December 2012 at 19:24:39 UTC, Rob T wrote:
On Friday, 14 December 2012 at 18:46:52 UTC, Peter Alexander
wrote:
Allocating memory is simply slow. The same is true in C++
where you will see performance hits if you allocate memory too
often. The GC makes things worse, but if you really care about
performance then you'll avoid allocating memory so often.
Try to pre-allocate as much as possible, and use the stack
instead of the heap where possible. Fixed size arrays and
structs are your friend.
In my situation, I can think of some ways to mitigate the
memory allocation problem, however it's a bit tricky when
SELECT statement results have to be dynamically generated,
since the number of rows returned and size and type of the rows
are always different depending on the query and the data stored
in the database. It's just not at all practical to custom fit
for each SELECT to a pre-allocated array or list, it'll just be
far too much manual effort.
Isn't the memory management completely negligible when compared
to the database access here ?