Board index » delphi » Data segment too large
Daniel
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
Daniel
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Data segment too largeHallo I hope you can help me. What is the simplest way to avoid the Please help me. Skriv Svenska om du kan. |
Jim Leona
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Data segment too largeQuoteIn article <32D53837.3...@hotmail.com>, Daniel <daniel...@hotmail.com> wrote: Seriously, though, convert your static structures (var thing:array[1..64000] of type var Look up new() and dispose() or getmem() and freemem() for more info. |
Mike Copelan
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Data segment too largeQuote> What is the simplest way to avoid the linked into the program - that's what the error is telling you: you have somehow caused more than 64K bytes of Var data to be referenced (and linked into the program). There are several things you can do (many of which we've done at one time or another): 1. Reduce the size/dimensions of your defined structures. This can entail such things as: using specific-length strings (string[n], rather than string); reduce array dimensions; use Byte arrays instead of integer/Word arrays (or use bit arrays instead of Byte arrays for flags), etc. 2. Establish multiple Var blocks in your global Units, so that only truly refenerced Var data is linked into specific programs. Note that a Unit which has 1 Var block of, say, 30K will link _all_ of that 30K into the Data Segment of a program which references only 1 variable in that Var block - the Smart Linker can't determine what of that Var block isn't actaully being used. So, realign/block your Units' Var data in some "application-specific" order, so that all/most of what's linked into a given program is actually referenced. This will take time/effort, but the payoff is major... 3. Use Pascal pointers to allocate/access large data structures: a pointer to a 300 byte structure consumes only 4 bytes of your (precious) Data Segment and 304 bytes of Heap space - of which you probably have about 400k to use - rather than 300 bytes of Data Segment...a big savings any time you can do this. 4. Use the Stack and procedure-local data for data which is used only by procedures. You have (up to) 64K of Stack, so it's possible to almost double the 64K of Var data by clever use of procedure-local and global data. So, there's much you can do, yet little of it is either easy or simple - you really must restructure your program's Data, usages, sizes and locations. It's a good idea to obtain a .MAP file from your (successful) compile/link, to examine what Data is being brought into your program and from where... |
DarkMoon Risin
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Data segment too largeQuote> 1. Reduce the size/dimensions of your defined structures. This can PChar works for me - it takes the length of the actual string without Quote> 2. Establish multiple Var blocks in your global Units, so that only ?? I thought the linker eliminated "dead" code and data. That's a good idea - I learned something here today. Quote> 3. Use Pascal pointers to allocate/access large data structures: a Yes, I use this for screen buffering. The explanation wasn't too good though, you use getmem(pointer,size) and then freemem(pointer,size) Quote> 4. Use the Stack and procedure-local data for data which is used only Just don't go overboard, a stack overflow sometimes means full system crash :) -- |