Out of Memory with Blob Field

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Out of Memory with Blob Field

Post by eduardosic » Mon 05 Dec 2016 23:43

Hi, i'm using mydac 8.4.11, Delphi 2007 and MariaDB 5, when i try to insert a file with 296 MB on a LongBlob Field mydac raise exception out of Memory.
With a 140MB file work's fine.

This is SQL in TMyQuery

Insert Into Files (ID, FILE) Values (:ID, :FILE);

QryInsert.ParamByName( 'ID' ).AsInteger := 999;
QryInsert.ParamByName( 'FILE' ).LoadFromFile( 'C:\Files\BigFile.Arq', ftBlob );
QryInsert.Execute;




Call Stack information:
--------------------------------------------------------------------------------------
|Address |Module |Unit |Class |Procedure/Method |Line |
--------------------------------------------------------------------------------------
|*Exception Thread: ID=1636; Priority=0; Class=; [Main] |
|------------------------------------------------------------------------------------|
|00406D26|BlobError.exe|System.pas | |DynArraySetLength | |
|0040316E|BlobError.exe|System.pas | |ErrorAt | |
|00402FB8|BlobError.exe|System.pas | |_ReallocMem | |
|00406D26|BlobError.exe|System.pas | |DynArraySetLength | |
|004053F8|BlobError.exe|System.pas | |_LStrClr | |
|0057DA9C|BlobError.exe|MyClasses.pas | |EscapeAndQuoteVar | |
|00406C6C|BlobError.exe|System.pas | |DynArraySetLength | |
|00406DFD|BlobError.exe|System.pas | |_DynArraySetLength| |
|00406DF8|BlobError.exe|System.pas | |_DynArraySetLength| |
|004E2910|BlobError.exe|CLRClasses.pas|AnsiStringBuilder|Append | |
|004E28D0|BlobError.exe|CLRClasses.pas|AnsiStringBuilder|Append | |
|0057E463|BlobError.exe|MyClasses.pas | |AppendA | |
|0057E43C|BlobError.exe|MyClasses.pas | |AppendA | |
|0057E5D1|BlobError.exe|MyClasses.pas | |AppendValueToSQL | |
|0057E4DC|BlobError.exe|MyClasses.pas | |AppendValueToSQL | |
|0057E3C8|BlobError.exe|MyClasses.pas | |AppendValueToSQL | |
|0057E3A4|BlobError.exe|MyClasses.pas | |AppendValueToSQL | |
|00583900|BlobError.exe|MyClasses.pas | |PlaceParamValues | |
|00583620|BlobError.exe|MyClasses.pas | |PlaceParamValues | |
|00583BCC|BlobError.exe|MyClasses.pas | |DoExecute | |
|00583A30|BlobError.exe|MyClasses.pas | |DoExecute | |
|00584021|BlobError.exe|MyClasses.pas |TMySQLCommand |Execute | |
|0053CF38|BlobError.exe|CRAccess.pas |TCRRecordSet |ExecCommand | |
|0053CF28|BlobError.exe|CRAccess.pas |TCRRecordSet |ExecCommand | |
|00584E1D|BlobError.exe|MyClasses.pas |TMySQLRecordSet |ExecCommand | |
|00552A74|BlobError.exe|DBAccess.pas |TCustomDADataSet |InternalExecute | |
|00552DFD|BlobError.exe|DBAccess.pas |TCustomDADataSet |Execute | |
|0059B5D7|BlobError.exe|Main.pas |TForm1 |Button1Click |37[8] |
|004A1D51|BlobError.exe|Controls.pas |TControl |Click |5229[9] |
|004A1CEC|BlobError.exe|Controls.pas |TControl |Click |5220[0] |
|00490921|BlobError.exe|StdCtrls.pas |TButton |Click |3745[3] |
|00404608|BlobError.exe|System.pas | |_CallDynaInst | |
|00490A37|BlobError.exe|StdCtrls.pas |TButton |CNCommand |3797[1] |
|004A184B|BlobError.exe|Controls.pas |TControl |WndProc |5146[83] |
|004A1590|BlobError.exe|Controls.pas |TControl |WndProc |5063[0] |
|004A56F3|BlobError.exe|Controls.pas |TWinControl |WndProc |7304[111]|
|004A51F8|BlobError.exe|Controls.pas |TWinControl |WndProc |7193[0] |
|004907B3|BlobError.exe|StdCtrls.pas |TButtonControl |WndProc |3684[13] |
|004A14D8|BlobError.exe|Controls.pas |TControl |Perform |5021[5] |
|004A14B4|BlobError.exe|Controls.pas |TControl |Perform |5016[0] |
|004A5843|BlobError.exe|Controls.pas | |DoControlMsg |7353[6] |
|004A5820|BlobError.exe|Controls.pas | |DoControlMsg |7347[0] |
|004A623B|BlobError.exe|Controls.pas |TWinControl |WMCommand |7616[1] |
|004A6230|BlobError.exe|Controls.pas |TWinControl |WMCommand |7615[0] |
|004B98E8|BlobError.exe|Forms.pas |TCustomForm |WMCommand |5016[3] |
|004A184B|BlobError.exe|Controls.pas |TControl |WndProc |5146[83] |
|004A1590|BlobError.exe|Controls.pas |TControl |WndProc |5063[0] |
|004A56F3|BlobError.exe|Controls.pas |TWinControl |WndProc |7304[111]|
|004A51F8|BlobError.exe|Controls.pas |TWinControl |WndProc |7193[0] |
|004B69D7|BlobError.exe|Forms.pas |TCustomForm |WndProc |3512[136]|
|004A4E1C|BlobError.exe|Controls.pas |TWinControl |MainWndProc |7073[3] |
|0042AC1C|BlobError.exe|Classes.pas | |StdWndProc | |
|75C996C0|USER32.dll | | |SendMessageW | |
|75CA7945|USER32.dll | | |CallWindowProcA | |
|75CA792F|USER32.dll | | |CallWindowProcA | |
|004A57EF|BlobError.exe|Controls.pas |TWinControl |DefaultHandler |7334[23] |
|004A2170|BlobError.exe|Controls.pas |TControl |WMLButtonUp |5360[1] |
|004A184B|BlobError.exe|Controls.pas |TControl |WndProc |5146[83] |
|004A1590|BlobError.exe|Controls.pas |TControl |WndProc |5063[0] |
|004A56F3|BlobError.exe|Controls.pas |TWinControl |WndProc |7304[111]|
|004A51F8|BlobError.exe|Controls.pas |TWinControl |WndProc |7193[0] |
|004907B3|BlobError.exe|StdCtrls.pas |TButtonControl |WndProc |3684[13] |
|004A4E1C|BlobError.exe|Controls.pas |TWinControl |MainWndProc |7073[3] |
|0042AC1C|BlobError.exe|Classes.pas | |StdWndProc | |
|75C97BC5|USER32.dll | | |DispatchMessageA | |
|75C97BBB|USER32.dll | | |DispatchMessageA | |
|004BE754|BlobError.exe|Forms.pas |TApplication |ProcessMessage |8105[23] |
|004BE658|BlobError.exe|Forms.pas |TApplication |ProcessMessage |8082[0] |
|004BE776|BlobError.exe|Forms.pas |TApplication |HandleMessage |8125[1] |
|004BE76C|BlobError.exe|Forms.pas |TApplication |HandleMessage |8124[0] |
|004BEA6B|BlobError.exe|Forms.pas |TApplication |Run |8224[20] |
|004BE9B8|BlobError.exe|Forms.pas |TApplication |Run |8204[0] |
|0059E24D|BlobError.exe|BlobError.dpr | |Initialization |14[4] |
--------------------------------------------------------------------------------------

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Re: Out of Memory with Blob Field

Post by eduardosic » Tue 06 Dec 2016 14:07

I test with MyDAC 8.7.27 trial and Delphi XE, work's fine, i go to upgrade my licence.
Thank's Devart.

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Re: Out of Memory with Blob Field

Post by eduardosic » Tue 06 Dec 2016 14:20

I test Mydac Trial 8.7.27 and Delphi 2007 and have Out of Memory :(
i sent a smal sample to reproduce the problem.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Out of Memory with Blob Field

Post by ViktorV » Tue 06 Dec 2016 14:31

The point is that to transmit large BLOB we should allocate one memory block in MySQL server. But when allocating a large amount of memory, free memory is not enough and the OutOfMemory error is generated.
We will try to improve the work with large BLOB in one of the next MyDAC releases.

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Re: Out of Memory with Blob Field

Post by eduardosic » Tue 06 Dec 2016 14:51

ViktorV, using Mydac 8.7.27 and Delphi XE, work's fine, but don't work with Delphi 2007

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Out of Memory with Blob Field

Post by ViktorV » Tue 06 Dec 2016 15:17

This behavior is related to work peculiarity of different Delphi versions. We will investigate why there is some difference in behavior depending on Delphi version and inform you about the result.

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Re: Out of Memory with Blob Field

Post by eduardosic » Wed 07 Dec 2016 14:58

Hi ViktorV, the exception happen in CRLClasses.pas, line 1177

Code: Select all

 SetLength(FString, FActualLength + ls + l shr 1); 
on adjust length of FString to a big size of blob, the exception only in Delphi 2007, on Delphi XE work's ok.
Memory manager of Delphi 2007?

eduardosic
Posts: 387
Joined: Fri 18 Nov 2005 00:26
Location: Brazil

Re: Out of Memory with Blob Field

Post by eduardosic » Wed 07 Dec 2016 15:07

Hi ViktorK,

setting

Code: Select all

{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
Solve the out of memory exception in Delphi 2007

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Out of Memory with Blob Field

Post by ViktorV » Fri 09 Dec 2016 14:14

We deleted the link, because it does not correspond to our company's policy. Only links to official sites can be posted on our forum.
The issue solution is a workaround. We are glad to hear that it helped to solve the problem. We will try to improve work with large blob in order for users not to use the mentioned workaround.

Post Reply