Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #11321
| From | "Fred Zwarts \(KVI\)" <F.Zwarts@KVI.nl> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Stack is slow than heap? |
| Date | 2011-11-08 17:28 +0100 |
| Organization | albasani.net |
| Message-ID | <j9blc6$f05$1@news.albasani.net> (permalink) |
| References | <3b85a1bb-7531-4d9c-9c18-77e93a5d52b7@r7g2000vbg.googlegroups.com> <e96924d8-9f73-406f-84ae-2a3aa372a3be@k26g2000yqd.googlegroups.com> <2ec220c4-7264-4980-8802-57ad7c3c66eb@s7g2000yqa.googlegroups.com> |
"Nephi Immortal" wrote in message news:2ec220c4-7264-4980-8802-57ad7c3c66eb@s7g2000yqa.googlegroups.com... > >On Nov 8, 5:00 am, Nick Keighley <nick_keighley_nos...@hotmail.com> >wrote: >> Include your question in the body of your post >> >> "Stack is slow than heap" >> >> maybe. It all depends on the implementaion. I'd expect access time to >> be very similar. Allocation/release is a little slower for heap >> (dynamic memory) than stack (automatic memory). > >Heap is slow unless you allocate and deallocate heap many times. >Heap is pretty fast if you allocate one time prior reaching main >function and deallocate one time after exiting main function. If you >insist, you have to allocate and deallocate very often, you will >implement your own memory pool to speed up performance. Heap and stack are usually accessing the same memory. So access times are not different. Only allocation/release times are different. Allocating/releasing stack is usually somewhat faster. > ... >> >> > After you write a function, do you prefer to store one buffer >> > to hold >> > 1,024 bytes or 4,096 bytes? >> >> I've never been given this option!. I'd choose the smaller number if >> 1024 bytes were enough for my function. Wouldn't it be a good idea to >> pick the correct number? >> >> > Should 4,096 bytes be sufficient to hold >> > buffer or small array in stack? >> >> this is a nonsense question. What is the buffer for? > >If you have multiple buffers outside function, you will need to >create one temporary buffer inside function and copy all multiple >buffers into one buffer before one buffer outputs to the screen like >printf() or cout << … << endl; >I guess temporary buffer should hold sufficient 4,096 bytes or less. It depends on what you want to do. If you want to output one line of text, then a buffer of about 100 characters may be sufficient. If you want to refresh a whole screen in one go, then it depends on the screen resolution and the possible values of one cell. A screen with a resolution of about 200 x 100 and about 200 possible values per cell will need already a buffer of at about 20000 bytes. > ...
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Stack is slow than heap? Nephi Immortal <immortalnephi@gmail.com> - 2011-11-07 08:27 -0800
Re: Stack is slow than heap? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-11-07 11:47 -0500
Re: Stack is slow than heap? BGB <cr88192@hotmail.com> - 2011-11-07 15:28 -0700
Re: Stack is slow than heap? Nephi Immortal <immortalnephi@gmail.com> - 2011-11-08 07:35 -0800
Re: Stack is slow than heap? "io_x" <a@b.c.invalid> - 2011-11-08 18:17 +0100
Re: Stack is slow than heap? Nephi Immortal <immortalnephi@gmail.com> - 2011-11-08 11:39 -0800
Re: Stack is slow than heap? "io_x" <a@b.c.invalid> - 2011-11-09 03:42 +0100
Re: Stack is slow than heap? "io_x" <a@b.c.invalid> - 2011-11-09 03:55 +0100
Re: Stack is slow than heap? "io_x" <a@b.c.invalid> - 2011-11-09 03:58 +0100
Re: Stack is slow than heap? Cholo Lennon <chololennon@hotmail.com> - 2011-11-08 17:52 -0300
Re: Stack is slow than heap? BGB <cr88192@hotmail.com> - 2011-11-09 00:09 -0700
Re: Stack is slow than heap? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-11-09 17:33 +0000
Re: Stack is slow than heap? Juha Nieminen <nospam@thanks.invalid> - 2011-11-10 06:44 +0000
Re: Stack is slow than heap? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-11-10 20:14 +0000
Re: Stack is slow than heap? Juha Nieminen <nospam@thanks.invalid> - 2011-11-10 21:01 +0000
Re: Stack is slow than heap? Cholo Lennon <chololennon@hotmail.com> - 2011-11-10 18:55 -0300
Re: Stack is slow than heap? Juha Nieminen <nospam@thanks.invalid> - 2011-11-11 07:37 +0000
Re: Stack is slow than heap? gwowen <gwowen@gmail.com> - 2011-11-11 02:18 -0800
Re: Stack is slow than heap? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-11-10 22:34 +0000
Re: Stack is slow than heap? Paavo Helde <myfirstname@osa.pri.ee> - 2011-11-09 14:38 -0600
Re: Stack is slow than heap? BGB <cr88192@hotmail.com> - 2011-11-09 15:30 -0700
Re: Stack is slow than heap? "io_x" <a@b.c.invalid> - 2011-11-07 19:32 +0100
Re: Stack is slow than heap? "io_x" <a@b.c.invalid> - 2011-11-07 19:50 +0100
Re: Stack is slow than heap? Edek <edek.pienkowski@gmail.com> - 2011-11-07 20:10 +0100
Re: Stack is slow than heap? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-08 03:00 -0800
Re: Stack is slow than heap? Nephi Immortal <immortalnephi@gmail.com> - 2011-11-08 07:45 -0800
Re: Stack is slow than heap? "Fred Zwarts \(KVI\)" <F.Zwarts@KVI.nl> - 2011-11-08 17:28 +0100
Re: Stack is slow than heap? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-09 02:20 -0800
Re: Stack is slow than heap? Werner <werasm@gmail.com> - 2011-11-09 03:03 -0800
Re: Stack is slow than heap? Dombo <dombo@disposable.invalid> - 2011-11-09 20:16 +0100
Re: Stack is slow than heap? Richard Damon <news.x.richarddamon@xoxy.net> - 2011-11-09 23:35 -0500
csiph-web