Sunday 20 November 2011

I get the message DGROUP: group exceeds 64K during my link. What’s wrong? in C programming

I get the message DGROUP: group exceeds 64K during my link. What’s wrong?

If you see this error message while linking your program, the linker is indicating that you have more than 64KB of near data (static data elements, global variables, and so on) in your data (DGROUP) segment. You can remedy this situation in a few ways:

Eliminate some of your global variables.
Decrease your program’s stack size.
Use dynamic memory allocation techniques to dynamically allocate data elements instead of defining them as static or global.
 Declare data elements specifically as far rather than near.

Eliminating some of your global variables will probably require some rework on your part as to the inherent design of your program, but it will be worth it when all is said and done. Global variables by nature tend to be somewhat of a maintenance nightmare and should be used only when absolutely necessary. If you have allocated a lot of space to be used as stack space, you might want to experiment with lowering the stack spacesize to see whether you can gain memory that way. If you are using a lot of static data in your program, tryto think of a way you could possibly rework your static data and allocate it dynamically rather than statically. This technique will free up the near heap and enable you to allocate data from the far heap instead (see FAQ XVIII.15 for a discussion on near and far heap space).

Cross Reference:

XVIII.12: How can I keep my program from running out of memory?
XVIII.13: My program is too big to run under DOS. How can I make it fit?
XVIII.14: How can I get more than 640KB of memory available to my DOS program?
XVIII.15: What is the difference between near and far?

1 comment: