Click here to Skip to main content
16,004,974 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Buffer Size Pin
David Crow12-Mar-07 4:31
David Crow12-Mar-07 4:31 
AnswerRe: Buffer Size Pin
John R. Shaw12-Mar-07 1:20
John R. Shaw12-Mar-07 1:20 
GeneralRe: Buffer Size Pin
Programm3r12-Mar-07 1:29
Programm3r12-Mar-07 1:29 
GeneralRe: Buffer Size Pin
John R. Shaw12-Mar-07 2:22
John R. Shaw12-Mar-07 2:22 
GeneralRe: Buffer Size Pin
Programm3r12-Mar-07 1:56
Programm3r12-Mar-07 1:56 
GeneralRe: Buffer Size Pin
BadKarma12-Mar-07 4:39
BadKarma12-Mar-07 4:39 
GeneralRe: Buffer Size Pin
John R. Shaw14-Mar-07 14:55
John R. Shaw14-Mar-07 14:55 
AnswerRe: Buffer Size Pin
James R. Twine12-Mar-07 2:22
James R. Twine12-Mar-07 2:22 
   The maximum size of a character buffer is what your software specifications specify!  If your application needs a buffer to handle 10 bytes of data, there is no need to allocate 2KB of memory.  The maximum size that you can allocate depends on the type of memory management being used.

[Stack]
   In Win32, your stack starts at 1MB, so depending on how your code works and where it is being called, you may be able to allocate much of that on the stack.  Grabbing 32KB from the stack is generally nothing unless you are dealing with recursive functions.

[RTL Memory Management]
   Allocating from the standard RTL heap imposes other limits, and these limits may be platform-specific.  For example on Win9x, you can only allocate a bit less than 256MB using the RTL allocation routines (this is a limitation of HeapAlloc(...) on Win9x).

[Win32 Memory Management]
   You can manage larger amounts of memory using things like VirtualAlloc(...), or using a memory-mapped file.  You can also run into address space exaustion when dealing with really large amounts of memory, but this is soemthing the average developer does not experience - at least, not unless they have a serious bug somewhere...

   The important thing to ask is how much memory do you need?  Some developers will scoff when they see something that they believe to be arbitrary buffer sizes of 32, 64, 128, 256, etc., but these limits are specified by the requirements of the software.  If your program needs a Username, and the specifications state that Username shall be limited to 31 characters, a character buffer size of 32 is perfectly fine.

   Peace!

-=- James
Please rate this message - let me know if I helped or not!<HR>If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFiles

GeneralRe: Buffer Size Pin
John R. Shaw12-Mar-07 2:31
John R. Shaw12-Mar-07 2:31 
GeneralRe: Buffer Size Pin
James R. Twine12-Mar-07 2:46
James R. Twine12-Mar-07 2:46 
GeneralRe: Buffer Size Pin
John R. Shaw12-Mar-07 3:08
John R. Shaw12-Mar-07 3:08 
GeneralRe: Buffer Size Pin
James R. Twine12-Mar-07 3:35
James R. Twine12-Mar-07 3:35 
GeneralRe: Buffer Size Pin
John R. Shaw12-Mar-07 4:37
John R. Shaw12-Mar-07 4:37 
AnswerRe: Buffer Size Pin
Stephen Hewitt12-Mar-07 13:18
Stephen Hewitt12-Mar-07 13:18 
QuestionListing hidden dir's Pin
sheetal_0611-Mar-07 20:30
sheetal_0611-Mar-07 20:30 
AnswerRe: Listing hidden dir's Pin
prasad_som11-Mar-07 21:17
prasad_som11-Mar-07 21:17 
QuestionRe: Listing hidden dir's Pin
David Crow12-Mar-07 4:34
David Crow12-Mar-07 4:34 
AnswerRe: Listing hidden dir's Pin
Hamid_RT12-Mar-07 5:37
Hamid_RT12-Mar-07 5:37 
QuestionNeed to display file open dialog in the center of the screen Pin
amitmistry_petlad 11-Mar-07 20:09
amitmistry_petlad 11-Mar-07 20:09 
AnswerRe: Need to display file open dialog in the center of the screen Pin
prasad_som11-Mar-07 20:15
prasad_som11-Mar-07 20:15 
GeneralRe: Need to display file open dialog in the center of the screen Pin
amitmistry_petlad 11-Mar-07 20:18
amitmistry_petlad 11-Mar-07 20:18 
AnswerRe: Need to display file open dialog in the center of the screen Pin
prasad_som11-Mar-07 20:35
prasad_som11-Mar-07 20:35 
GeneralRe: Need to display file open dialog in the center of the screen Pin
amitmistry_petlad 11-Mar-07 19:42
amitmistry_petlad 11-Mar-07 19:42 
AnswerRe: Need to display file open dialog in the center of the screen Pin
prasad_som11-Mar-07 20:57
prasad_som11-Mar-07 20:57 
GeneralRe: Need to display file open dialog in the center of the screen Pin
John R. Shaw11-Mar-07 20:57
John R. Shaw11-Mar-07 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.