Wednesday 16 November 2011

What are the most commonly used memory models? in C programming

What are the most commonly used memory models?

The most common are the Small, Medium, and Large memory models. The Tiny memory model is typically used only for creation of .COM files, which is somewhat rare in today’s world of high-powered machines. The Compact memory model allows your program to have very little code and a lot of data. This, too, is uncommon in today’s business place, because very often you will find significant amounts of code where there are significant amounts of data. The Huge memory model is somewhat inefficient because of the memory addressing scheme it imposes, and it is also a rarity.

Typically, you should use the Small, Medium, or Large memory models, depending on the size of your program. For a small utility program, the Small memory model might be suitable. This memory model enables you to have 64KB of code and 64KB for your data and stack. If your program has slightly larger data requirements than this, you might want to use the Medium memory model, which enables you to have up to 1 megabyte of addressable data space. For larger programs, you will want to use the Large memory model, which enables you to have 1 megabyte of code and 1 megabyte of data and stack space.

If you are writing a Windows program or using a 32-bit compiler, you will use the Small memory model. This is because such environments are not restricted to the segmented architecture of DOS programs.

Cross Reference:

XVIII.2: What are the differences between the memory models?
XVIII.4: Which memory model should be used?

No comments:

Post a Comment