天
天真男孩
Unregistered / Unconfirmed
GUEST, unregistred user!
每运行一下,内存就增加一次?
该怎么写来释放?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
PData=^TData;
TData=record
ip:string;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function MyThreadping(Ptrointer):integer;stdcall;
var
ls_ip:string;
DataData;
begin
Data:=PData(Ptr);
ls_ip:=Data^.ip;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ThreadIDWord;
DataData;
i:integer;
begin
for i:=1 to 1000do
begin
New(Data);
Data^.ip:=inttostr(i);
CreateThread(nil,0,@MyThreadping,Data,0,ThreadID);
//dispose(Data);
这上这句就报内存出错
end;
end;
end.
该怎么写来释放?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
PData=^TData;
TData=record
ip:string;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function MyThreadping(Ptrointer):integer;stdcall;
var
ls_ip:string;
DataData;
begin
Data:=PData(Ptr);
ls_ip:=Data^.ip;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ThreadIDWord;
DataData;
i:integer;
begin
for i:=1 to 1000do
begin
New(Data);
Data^.ip:=inttostr(i);
CreateThread(nil,0,@MyThreadping,Data,0,ThreadID);
//dispose(Data);
这上这句就报内存出错
end;
end;
end.