|
Boost Users : |
From: gast128 (gast128_at_[hidden])
Date: 2007-07-30 07:40:07
Bill Lear <rael <at> zopyra.com> writes:
>
> I have been searching the world in vain for a stringstream that works
> with a static buffer, and does not use the heap for memory allocation.
> We have an application that uses lots (12-16Gb) of memory. This puts
> a strain on the memory allocation routines, and when we want to create
> a small string we find that stringstream is very, very expensive, and
> sprintf into a static buffer much, much faster.
>
> Does boost provide anything like this?
>
> This actually came up when we realized that boost lexical_cast was
> using stringstream. When we replaced it with sprintf, our runtimes
> (when memory usage was very high) went down significantly. I should
> also point out that ANYTHING we did with dynamic memory at that point
> in the application (vector::push_back, for example) was hideously
> slow.
>
> I'd like to have the best of both worlds: the relatively clear
> syntax of the ostringstream inserters, working on a static buffer.
>
> Any help (code samples especially) appreciated.
>
> Bill
I wrote some while ago a wrapper which writes to a static buffer and flushes
then to the debugger output window. One can easily write things like:
dbg_cout << 2 << "Hello" << std::endl
It originates from the book 'Standard C++ IOStreams and Locales' 3.4.1.1.2 and
is basically an adapter of a 'basic_streambuf'. The iostream library is not
easy to plug in, and I think that Boost Iostreams helps in this area.
Unfortunately I haven't worked with it yet.
If you are interested I can mail you the code, but since it is not a Boost
topic I better not show it here...
wkr,
me
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net