Autor Beitrag
nepleurepas
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164

Win XP

BeitragVerfasst: Mi 25.04.07 17:39 
Hallo habe folgendes Array/record deklariert:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
type
Tsterndaten = record
  name: string;
  Jahr: integer;
  x: real;
  y: real;
end;

implementation
var bank: array [1..3508, 1..100] of Tsterndaten;


Bei start der procedure kommt der fehler "...raised exception class Estackoverflow...message overflow"

Kann dass daher kommen dass das record zu groß ist? Was ist dei maximale Größe einer kombination record array?

Danke für Antworten
gruß Stefan
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 25.04.07 17:50 
Moin!

Das liegt vermutlich eher daran, dass das Array statisch deklariert ist. Warum machst du das Array nicht dynamisch? :nixweiss: Auf dem Heap ist "genügend" Platz... :P

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
nepleurepas Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164

Win XP

BeitragVerfasst: Mi 25.04.07 18:00 
user profile iconNarses hat folgendes geschrieben:
Moin!

Das liegt vermutlich eher daran, dass das Array statisch deklariert ist. Warum machst du das Array nicht dynamisch? :nixweiss: Auf dem Heap ist "genügend" Platz... :P

cu
Narses


Kannst du mir sagen wie eine dynamische deklaration aussehen würde? Hab das bis jetzt nicht so hingekriet. Muss ich das dynamische dann schrittweiße vergrößern, oder kann ich gleich zu begin der procedure die größe festlegen?

stefan
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 25.04.07 18:29 
Moin!

Lass bei der Deklaration einfach die Dimension(en) weg. Zur Laufzeit dann mit SetLength()die benötigte Größe setzen. Du kannst ein dyn. Array auch zur Laufzeit vergrößern, allerdings solltest du das nicht in 1er-Schritten tun, immer direkt "große" Blöcke anfordern, sonst vergurkt der DelphiMM zuviel RAM... :?

Ich empfehle die Delphi-OH oder die Forumssuche als Lektüre! :mahn: :les: ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mi 25.04.07 18:58 
(a) Lektüre empfehle ich auch
(b)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
TMyDataArray = array of array of TSternDate;
var 
  bank: TMyDataArray;
//init/Soeicher resevieren
SetLength(bank,3508,100];
//Achtung Indizes beginne jetzt bei Null
//Done/freigeben
Finalize(Bank);

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Hobby-Programmierer
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 238
Erhaltene Danke: 4

Win XP Pro, Vista Ultimate Trial :o)
D6 Pro, D7 Pro, Turbo, XE SE
BeitragVerfasst: Mi 25.04.07 21:34 
Nabend ...,
ausserdem solltest du die Länge der Stringvariablen innerhalb des Records begrenzen. :les: ShortString
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
type
Tsterndaten = record
  name: string[255];
  Jahr: integer;
  x: real;
  y: real;
end;


LG Mario
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 25.04.07 21:39 
Moin!

user profile iconHobby-Programmierer hat folgendes geschrieben:
ausserdem solltest du die Länge der Stringvariablen innerhalb des Records begrenzen

Warum? :nixweiss: :gruebel: Ist im Zweifel eher ein Nachteil, wenn er viele Elemente anlegt, aber (noch) nicht braucht, weil die record-netto-Größe damit ansteigt! :mahn:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.