Page 1 of 1

Out of Memory with Blob Field

Posted: Mon 05 Dec 2016 23:43
by eduardosic
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] |
--------------------------------------------------------------------------------------

Re: Out of Memory with Blob Field

Posted: Tue 06 Dec 2016 14:07
by eduardosic
I test with MyDAC 8.7.27 trial and Delphi XE, work's fine, i go to upgrade my licence.
Thank's Devart.

Re: Out of Memory with Blob Field

Posted: Tue 06 Dec 2016 14:20
by eduardosic
I test Mydac Trial 8.7.27 and Delphi 2007 and have Out of Memory :(
i sent a smal sample to reproduce the problem.

Re: Out of Memory with Blob Field

Posted: Tue 06 Dec 2016 14:31
by ViktorV
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.

Re: Out of Memory with Blob Field

Posted: Tue 06 Dec 2016 14:51
by eduardosic
ViktorV, using Mydac 8.7.27 and Delphi XE, work's fine, but don't work with Delphi 2007

Re: Out of Memory with Blob Field

Posted: Tue 06 Dec 2016 15:17
by ViktorV
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.

Re: Out of Memory with Blob Field

Posted: Wed 07 Dec 2016 14:58
by eduardosic
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?

Re: Out of Memory with Blob Field

Posted: Wed 07 Dec 2016 15:07
by eduardosic
Hi ViktorK,

setting

Code: Select all

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

Re: Out of Memory with Blob Field

Posted: Fri 09 Dec 2016 14:14
by ViktorV
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.