Bonjour,
Sur une application de test il est possible que je doive stocker de 2 à plusieurs milliards d'enregistrements.
Dans ma procédure j'ai la variable suivante :
Au fur et à mesure j'ajoute des points, au bout d'un moment j'obtiens un "Mémoire insuffisante" à environ 50 millions d'items.
Code : Sélectionner tout - Visualiser dans une fenêtre à part ListChemins : TList<TPoint>;
J'ai une boucle ou pour passer à l'item suivant il faut respecter une conditions sinon je recommence jusqu’à l'atteindre. Avant la boucle j'ajoute un point de coordonnées X=0 et Y=0.
Si j'utilise le SetLocation au lieu du TPoint.Create sur l'affectation j'ai directement un mémoire insuffisante et je ne vois pas pourquoi..
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 procedure TForm2.btnCalculerClick(Sender: TObject); var i : integer; iTermine : integer; ListChemins: TList<TPoint>; iWidth : integer; begin iWidth := seEdit.Value; ListChemins := TList<TPoint>.Create; iTermine := 0; i := 0; try ListChemins.Add(TPoint.Create(0, 0)); while i <= ListChemins.Count - 1 do begin if (ListChemins[i].X < iWidth) and (ListChemins[i].Y < iWidth) then begin ListChemins.Add(TPoint.Create(ListChemins[i].X, ListChemins[i].Y + 1)); ListChemins[i] := TPoint.Create(ListChemins[i].X + 1, ListChemins[i].Y); Dec(i); end else if ListChemins[i].X < iWidth then begin ListChemins[i] := TPoint.Create(ListChemins[i].X + 1, ListChemins[i].Y); Dec(i); end else if ListChemins[i].Y < iWidth then begin ListChemins[i] := TPoint.Create(ListChemins[i].X, ListChemins[i].Y + 1); Dec(i); end else begin Inc(iTermine); end; Inc(i); end; lbTotal.Caption := iTermine.ToString; finally for i := ListChemins.Count - 1 downto 0 do ListChemins.Delete(i); FreeAndNil(ListChemins); end; end;
C'est sur que au bout d'un moment boucler sur des ensembles aussi grands .. mais j'ai vraiment besoin de garder en mémoire le contenu de la liste.
Auriez vous une idée pour éviter cette erreur ?
Merci
Partager