Well, slap me silly!
Hmm... well, first, I would consider myself a "beginner" C++ programmer not far past the "newbie" stage. Anyway, in all the programs i have written, i have used the heap for storage of any data structures much bigger than an average string. I''ve been talking with this pascal programmer, and he claims that that method is outdated, and that it is better practice to make all your variables global and declare them at the start of the program. ??? Comments?
The heap would be used for data storage where you don''t know the size needed in advance, or for temporary storage.
Using globals is sometimes called bad practice by many programmers, but they are useful. Personally, I''d only store basic data needed by the majority of my program in globals (i.e. Main window handle/Instance etc.)
I don''t know about PASCAL, but in C++, using the heap (with new and delete) is common practice, although for performance using it a lot is undesirable - you have to be careful with your management.
Using globals is sometimes called bad practice by many programmers, but they are useful. Personally, I''d only store basic data needed by the majority of my program in globals (i.e. Main window handle/Instance etc.)
I don''t know about PASCAL, but in C++, using the heap (with new and delete) is common practice, although for performance using it a lot is undesirable - you have to be careful with your management.
I wouldn''t take any advice from a Pascal programmer since they''ve already made a serious mistake
Stack storage is preferred over heap storage, because lots of little new/deletes can fragment your apps heap space.
Eventually Windows has to either go and get a new page (could be avialable, maybe need to swap to disk...), deny the memory request (BOOM!), or do garage collection.
I''m not sure exactly what it''ll do, but I know it won''t be good.
If the thing it represents is global, then its variable/pointer should be global...
Stack storage is preferred over heap storage, because lots of little new/deletes can fragment your apps heap space.
Eventually Windows has to either go and get a new page (could be avialable, maybe need to swap to disk...), deny the memory request (BOOM!), or do garage collection.
I''m not sure exactly what it''ll do, but I know it won''t be good.
If the thing it represents is global, then its variable/pointer should be global...
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Thanks guys, I think I get the picture now. For some reason, I was thinking that the stack was a little, partitioned-off section of mem and the rest was heap. Dunno how I got that image...
Everything becomes clear now... sort of. At least a lot less dim. Can anyone point me to an article regarding the specifics of how Windows handles memory? I just realized that I have a lot to learn on the subject.
Everything becomes clear now... sort of. At least a lot less dim. Can anyone point me to an article regarding the specifics of how Windows handles memory? I just realized that I have a lot to learn on the subject.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement