JPG图片以二进制格式保存进Oracle数据库过程中内存释放不干净!请高手指点代码中的缺陷 ( 积分: 100 )

  • 主题发起人 主题发起人 top99010
  • 开始时间 开始时间
T

top99010

Unregistered / Unconfirmed
GUEST, unregistred user!
存储约50K的JPG图片70张以后占用内存增加了7M,下一个循环70张又逐步增加7M,内存始终无法恢复到存储前的状态值,1000张以后系统基本停滞了,高手救急!
procedure TSaverRecord.SavePicture;//图片存储
var
JPGPic: TJpegImage;
JPGStream: TMemoryStream;
begin
with Image1 do
begin
if Picture.Graphic = nil then
exit;
try
JPGPic := TJpegImage.Create;
JPGPic.Assign(Picture.Graphic);
//BMP格式转换JPG
JPGPic.CompressionQuality := 90;//压缩率
JPGPic.Compress;
JPGPic.JPEGNeeded;
JPGStream := TMemoryStream.Create;
JPGStream.SaveToStream(LMSM_Media);
JPGStream.Position := 0;
if JPGStream <> nil then
begin
try
ADODataSet1.append;
TBlobField(ADODataSet1.FieldbyName(Image)).LoadFromStream(LMSM_Media);//存储数据库
ADODataSet1.Post;
except
end;
end;
finally
JPGPic.Free;
JPGStream.Free;
end;
end;
end;
 
存储约50K的JPG图片70张以后占用内存增加了7M,下一个循环70张又逐步增加7M,内存始终无法恢复到存储前的状态值,1000张以后系统基本停滞了,高手救急!
procedure TSaverRecord.SavePicture;//图片存储
var
JPGPic: TJpegImage;
JPGStream: TMemoryStream;
begin
with Image1 do
begin
if Picture.Graphic = nil then
exit;
try
JPGPic := TJpegImage.Create;
JPGPic.Assign(Picture.Graphic);
//BMP格式转换JPG
JPGPic.CompressionQuality := 90;//压缩率
JPGPic.Compress;
JPGPic.JPEGNeeded;
JPGStream := TMemoryStream.Create;
JPGStream.SaveToStream(LMSM_Media);
JPGStream.Position := 0;
if JPGStream <> nil then
begin
try
ADODataSet1.append;
TBlobField(ADODataSet1.FieldbyName(Image)).LoadFromStream(LMSM_Media);//存储数据库
ADODataSet1.Post;
except
end;
end;
finally
JPGPic.Free;
JPGStream.Free;
end;
end;
end;
 
ADODataSet1包含的数据集有没有释放呢
 
增加记录前
ADODataSet1.close;
 
后退
顶部