bonjour
J'ai un problème de fuites mémoires. Ca devrait être simple pour vous de répondre. Voici mon problème:
J'utilise memCheck pour pister les fuites mémoire.
Une form avec un combobox dessus, et un bouton.
Dans mon code, une fonction :
puis sur le onClick du button:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 Function RetournerTStringList():TStringList; begin Result:=TStringList.Create(); Result.Add('2344°'); end;
A la fin de l'exécution, memcheck ouvre le notepad et me sort ça:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 procedure TForm1.Button2Click(Sender: TObject); begin combobox1.Items.Clear; Combobox1.Items.AddStrings(RetournerTStringList); end;
Bon désolé c'est un peu gros...
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214 MemCheck version 2.75 TOP 10 Leaks: begin Leak #2 User allocated memory (GetMem) Size: 48 1 Occurence call stack - 0 : (no debug info) Find error: 40003A45 call stack - 1 : Module Unit1.pas Routine @Unit1@TForm1@Button2Click Line 131 Find error: 004081B9 call stack - 2 : (no debug info) Find error: 4006B794 call stack - 3 : (no debug info) Find error: 40047D19 call stack - 4 : (no debug info) Find error: 4006E2E4 call stack - 5 : (no debug info) Find error: 40053FF3 call stack - 6 : (no debug info) Find error: 4006DDB7 call stack - 7 : (no debug info) Find error: 400510B2 call stack - 8 : (no debug info) Find error: 7E398730 call stack - 9 : (no debug info) Find error: 7E398812 call stack - 10 : (no debug info) Find error: 7E39C63B call stack - 11 : (no debug info) Find error: 7E39C661 call stack - 12 : (no debug info) Find error: 58B55E5A call stack - 13 : (no debug info) Find error: 58B5602B call stack - 14 : (no debug info) Find error: 58B55FE0 call stack - 15 : (no debug info) Find error: 58B904BB call stack - 16 : (no debug info) Find error: 58B5602B call stack - 17 : (no debug info) Find error: 58B560BA call stack - 18 : (no debug info) Find error: 7E398730 call stack - 19 : (no debug info) Find error: 7E398812 call stack - 20 : (no debug info) Find error: 7E39B897 call stack - 21 : (no debug info) Find error: 7E39B8FF call stack - 22 : (no debug info) Find error: 7E3CFD19 call stack - 23 : (no debug info) Find error: 7E3C655D call stack - 24 : (no debug info) Find error: 7E3A6DF0 call stack - 25 : (no debug info) Find error: 7E3BB046 call stack - 26 : (no debug info) Find error: 7E398730 Leak #1 User allocated memory (GetMem) Size: 32 1 Occurence call stack - 0 : (no debug info) Find error: 02687500 call stack - 1 : Module Unit1.pas Routine @Unit1@TForm1@Button2Click Line 131 Find error: 004081B9 call stack - 2 : (no debug info) Find error: 4006B794 call stack - 3 : (no debug info) Find error: 40047D19 call stack - 4 : (no debug info) Find error: 4006E2E4 call stack - 5 : (no debug info) Find error: 40053FF3 call stack - 6 : (no debug info) Find error: 4006DDB7 call stack - 7 : (no debug info) Find error: 400510B2 call stack - 8 : (no debug info) Find error: 7E398730 call stack - 9 : (no debug info) Find error: 7E398812 call stack - 10 : (no debug info) Find error: 7E39C63B call stack - 11 : (no debug info) Find error: 7E39C661 call stack - 12 : (no debug info) Find error: 58B55E5A call stack - 13 : (no debug info) Find error: 58B5602B call stack - 14 : (no debug info) Find error: 58B55FE0 call stack - 15 : (no debug info) Find error: 58B904BB call stack - 16 : (no debug info) Find error: 58B5602B call stack - 17 : (no debug info) Find error: 58B560BA call stack - 18 : (no debug info) Find error: 7E398730 call stack - 19 : (no debug info) Find error: 7E398812 call stack - 20 : (no debug info) Find error: 7E39B897 call stack - 21 : (no debug info) Find error: 7E39B8FF call stack - 22 : (no debug info) Find error: 7E3CFD19 call stack - 23 : (no debug info) Find error: 7E3C655D call stack - 24 : (no debug info) Find error: 7E3A6DF0 call stack - 25 : (no debug info) Find error: 7E3BB046 call stack - 26 : (no debug info) Find error: 7E398730 Leak #0 User allocated memory (GetMem) Size: 14 1 Occurence call stack - 0 : (no debug info) Find error: 40004BB5 call stack - 1 : Module Unit1.pas Routine @Unit1@TForm1@Button2Click Line 131 Find error: 004081B9 call stack - 2 : (no debug info) Find error: 4006B794 call stack - 3 : (no debug info) Find error: 40047D19 call stack - 4 : (no debug info) Find error: 4006E2E4 call stack - 5 : (no debug info) Find error: 40053FF3 call stack - 6 : (no debug info) Find error: 4006DDB7 call stack - 7 : (no debug info) Find error: 400510B2 call stack - 8 : (no debug info) Find error: 7E398730 call stack - 9 : (no debug info) Find error: 7E398812 call stack - 10 : (no debug info) Find error: 7E39C63B call stack - 11 : (no debug info) Find error: 7E39C661 call stack - 12 : (no debug info) Find error: 58B55E5A call stack - 13 : (no debug info) Find error: 58B5602B call stack - 14 : (no debug info) Find error: 58B55FE0 call stack - 15 : (no debug info) Find error: 58B904BB call stack - 16 : (no debug info) Find error: 58B5602B call stack - 17 : (no debug info) Find error: 58B560BA call stack - 18 : (no debug info) Find error: 7E398730 call stack - 19 : (no debug info) Find error: 7E398812 call stack - 20 : (no debug info) Find error: 7E39B897 call stack - 21 : (no debug info) Find error: 7E39B8FF call stack - 22 : (no debug info) Find error: 7E3CFD19 call stack - 23 : (no debug info) Find error: 7E3C655D call stack - 24 : (no debug info) Find error: 7E3A6DF0 call stack - 25 : (no debug info) Find error: 7E3BB046 call stack - 26 : (no debug info) Find error: 7E398730 TOP 10 Leaks: end Total leak: 94 bytes *** MEMCHK: Blocks STILL allocated *** Leak #0 User allocated memory (GetMem) Size: 14 1 Occurence call stack - 0 : (no debug info) Find error: 40004BB5 call stack - 1 : Module Unit1.pas Routine @Unit1@TForm1@Button2Click Line 131 Find error: 004081B9 call stack - 2 : (no debug info) Find error: 4006B794 call stack - 3 : (no debug info) Find error: 40047D19 call stack - 4 : (no debug info) Find error: 4006E2E4 call stack - 5 : (no debug info) Find error: 40053FF3 call stack - 6 : (no debug info) Find error: 4006DDB7 call stack - 7 : (no debug info) Find error: 400510B2 call stack - 8 : (no debug info) Find error: 7E398730 call stack - 9 : (no debug info) Find error: 7E398812 call stack - 10 : (no debug info) Find error: 7E39C63B call stack - 11 : (no debug info) Find error: 7E39C661 call stack - 12 : (no debug info) Find error: 58B55E5A call stack - 13 : (no debug info) Find error: 58B5602B call stack - 14 : (no debug info) Find error: 58B55FE0 call stack - 15 : (no debug info) Find error: 58B904BB call stack - 16 : (no debug info) Find error: 58B5602B call stack - 17 : (no debug info) Find error: 58B560BA call stack - 18 : (no debug info) Find error: 7E398730 call stack - 19 : (no debug info) Find error: 7E398812 call stack - 20 : (no debug info) Find error: 7E39B897 call stack - 21 : (no debug info) Find error: 7E39B8FF call stack - 22 : (no debug info) Find error: 7E3CFD19 call stack - 23 : (no debug info) Find error: 7E3C655D call stack - 24 : (no debug info) Find error: 7E3A6DF0 call stack - 25 : (no debug info) Find error: 7E3BB046 call stack - 26 : (no debug info) Find error: 7E398730 Leak #1 User allocated memory (GetMem) Size: 32 1 Occurence call stack - 0 : (no debug info) Find error: 02687500 call stack - 1 : Module Unit1.pas Routine @Unit1@TForm1@Button2Click Line 131 Find error: 004081B9 call stack - 2 : (no debug info) Find error: 4006B794 call stack - 3 : (no debug info) Find error: 40047D19 call stack - 4 : (no debug info) Find error: 4006E2E4 call stack - 5 : (no debug info) Find error: 40053FF3 call stack - 6 : (no debug info) Find error: 4006DDB7 call stack - 7 : (no debug info) Find error: 400510B2 call stack - 8 : (no debug info) Find error: 7E398730 call stack - 9 : (no debug info) Find error: 7E398812 call stack - 10 : (no debug info) Find error: 7E39C63B call stack - 11 : (no debug info) Find error: 7E39C661 call stack - 12 : (no debug info) Find error: 58B55E5A call stack - 13 : (no debug info) Find error: 58B5602B call stack - 14 : (no debug info) Find error: 58B55FE0 call stack - 15 : (no debug info) Find error: 58B904BB call stack - 16 : (no debug info) Find error: 58B5602B call stack - 17 : (no debug info) Find error: 58B560BA call stack - 18 : (no debug info) Find error: 7E398730 call stack - 19 : (no debug info) Find error: 7E398812 call stack - 20 : (no debug info) Find error: 7E39B897 call stack - 21 : (no debug info) Find error: 7E39B8FF call stack - 22 : (no debug info) Find error: 7E3CFD19 call stack - 23 : (no debug info) Find error: 7E3C655D call stack - 24 : (no debug info) Find error: 7E3A6DF0 call stack - 25 : (no debug info) Find error: 7E3BB046 call stack - 26 : (no debug info) Find error: 7E398730 Leak #2 User allocated memory (GetMem) Size: 48 1 Occurence call stack - 0 : (no debug info) Find error: 40003A45 call stack - 1 : Module Unit1.pas Routine @Unit1@TForm1@Button2Click Line 131 Find error: 004081B9 call stack - 2 : (no debug info) Find error: 4006B794 call stack - 3 : (no debug info) Find error: 40047D19 call stack - 4 : (no debug info) Find error: 4006E2E4 call stack - 5 : (no debug info) Find error: 40053FF3 call stack - 6 : (no debug info) Find error: 4006DDB7 call stack - 7 : (no debug info) Find error: 400510B2 call stack - 8 : (no debug info) Find error: 7E398730 call stack - 9 : (no debug info) Find error: 7E398812 call stack - 10 : (no debug info) Find error: 7E39C63B call stack - 11 : (no debug info) Find error: 7E39C661 call stack - 12 : (no debug info) Find error: 58B55E5A call stack - 13 : (no debug info) Find error: 58B5602B call stack - 14 : (no debug info) Find error: 58B55FE0 call stack - 15 : (no debug info) Find error: 58B904BB call stack - 16 : (no debug info) Find error: 58B5602B call stack - 17 : (no debug info) Find error: 58B560BA call stack - 18 : (no debug info) Find error: 7E398730 call stack - 19 : (no debug info) Find error: 7E398812 call stack - 20 : (no debug info) Find error: 7E39B897 call stack - 21 : (no debug info) Find error: 7E39B8FF call stack - 22 : (no debug info) Find error: 7E3CFD19 call stack - 23 : (no debug info) Find error: 7E3C655D call stack - 24 : (no debug info) Find error: 7E3A6DF0 call stack - 25 : (no debug info) Find error: 7E3BB046 call stack - 26 : (no debug info) Find error: 7E398730 *** MEMCHK: End of allocated blocks *** *** MEMCHK: Chronological leak information *** * User allocated memory (GetMem) (Leak #2) Size: 48 * User allocated memory (GetMem) (Leak #1) Size: 32 * User allocated memory (GetMem) (Leak #0) Size: 14 *** MEMCHK: End of chronological leak information *** *** MEMCHK: Blocks written to after destruction *** Bad blocks count: 0 *** MEMCHK: End of blocks written to after destruction ***
Je ne sais pas comment libérer le result que je crée. Pouvez vous me dire comment je dois écrire ma fonction qui renvoie un TStringList?
PS: quand je n'appelle pas la fonction qui renvoie la stringlist, memCheck n'apparait pas, donc pas de fuite mémoire.
Merci
Edit:
J'ai rajouté un bien moche:
aprés le ComboBox1.Items.Add et j'ai une runtime error. De toutes façons ça me paraissait bizarre de faire ça...
Code : Sélectionner tout - Visualiser dans une fenêtre à part Combobox1.Items.Free;
Partager