UniSQL Memory Leak (Oracle field: Timestamp)

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
andrefm
Posts: 37
Joined: Wed 23 Oct 2013 10:02

UniSQL Memory Leak (Oracle field: Timestamp)

Post by andrefm » Tue 01 Mar 2016 12:57

Hi,
I have in an Oracle DB a column of type: TIMESTAMP(6)

I'm getting memory leak when I execute the following query in a TUniSQL

SQL:
insert into TABLE (ID,SENDINGTIME,REASON)
values (IDSeq.nextval, sysdate, :Reason)

Execution:
UniSQL1.ParamByName('Reason').value := 'Test';
UniSQL1.Execute;

Memory Leak:
--------------------------------2016/3/1 23:48:45--------------------------------
A memory block has been leaked. The size is: 4

This block was allocated by thread 0x1444, and the stack trace (return addresses) at the time was:
406E86
72F483 [CLRClasses][CLRClasses][CLRClasses.Marshal.ReallocHGlobal]
8AE9E2 [OraClassesUni][OraClassesUni][OraClassesUni.TOraTimeStamp.Init]
8AE955 [OraClassesUni][OraClassesUni][OraClassesUni.TOraTimeStamp.Create]
8AA5C7 [OraClassesUni][OraClassesUni][OraClassesUni.TOCIRecordSet.FetchArray]
439DE4 [System.Variants][System][System.Variants.VarClearDeep]
439DE9 [System.Variants][System][System.Variants.VarClearDeep]
439E7A [System.Variants][System][System.Variants.@VarClear]
439E82 [System.Variants][System][System.Variants.@VarClr]
8A8EEF [OraClassesUni][OraClassesUni][OraClassesUni.TOCIRecordSet.DoBeforeFetch]
7C3BA4 [CRAccess][CRAccess][CRAccess.TCRRecordSet.Fetch]

The block is currently used for an object of class: Unknown

The allocation number is: 261747

-------------------
Environment:
- Delphi 10 with Update 1
- Unidac 6.2.10
- Oracle DB 10.2.0.2.0 64bit (Linux server)

If you need further information, please let me know.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UniSQL Memory Leak (Oracle field: Timestamp)

Post by MaximG » Wed 02 Mar 2016 13:57

We have investigated the ODAC behavior on using TimeStamp data types. Unfortunately, we couldn't detect memory leaks in such case. Please specify the tool you used to detect memory leaks. For further investigation, please compose a complete sample demonstrating the issue and send it to maximg*devart*com.

andrefm
Posts: 37
Joined: Wed 23 Oct 2013 10:02

Re: UniSQL Memory Leak (Oracle field: Timestamp)

Post by andrefm » Tue 29 Mar 2016 02:19

Sorry, it took me long time as I was away but Today I was able to spend MANY HOURS to get my program apart and prepare a simple sample to simulate the memory leak. The memory leak was detected via FASTMM4.

Environment:
Delphi 10
UNIDAC 6.2.10

Below the details. If you still need something else, please let me know.

Please insert some records using the Button1.

TABLE:

Code: Select all

CREATE TABLE "MO_TMP" 
   (  "ID" NUMBER(19,0) NOT NULL ENABLE, 
  "VERSION" NUMBER(10,0) NOT NULL ENABLE, 
  "REASON" VARCHAR2(255 CHAR), 
  "PRIORITY" NUMBER(10,0) NOT NULL ENABLE, 
  "WEIGHT" NUMBER(19,0), 
  "CANCELLATIONTIME" TIMESTAMP (6), 
  "SENDINGTIME" TIMESTAMP (6), 
  "LOAD_ID" NUMBER(19,0) NOT NULL ENABLE, 
  "SOURCELOC" NUMBER(19,0) NOT NULL ENABLE, 
  "UPDATED" TIMESTAMP (6), 
  "CREATED" TIMESTAMP (6), 
  "UPDATEDBY" VARCHAR2(255 CHAR), 
  "CREATEDBY" VARCHAR2(255 CHAR), 
  "LASTLOAD" NUMBER(1,0), 
   PRIMARY KEY ("ID")
)   ;
  
SOURCE:

Code: Select all

procedure TForm2.Button1Click(Sender: TObject);
begin
   UniSQL1.tag := UniSQL1.tag + 1;
   UniSQL1.ParamByName('ve').value := UniSQL1.tag;
   UniSQL1.Execute;
end;

procedure TForm2.Button2Click(Sender: TObject);
begin
   Uniquery1.active := true;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
   UniConnection.Connected := true;
end;

FORM SOURCE (Relevant part only):

Code: Select all

  object UniSQL1: TUniSQL
    Connection = UniConnection
    SQL.Strings = (

        'insert into MO_TMP (ID,VERSION,REASON,PRIORITY,LOAD_ID, SOURCELO' +
        'C, CREATED, CREATEDBY)'

        ' values (mo_tmp_seq.nextval, :ve ,'#39'TEST'#39', 6, 234567, 98765, sysd' +
        'ate, '#39'my_program'#39')')
    Left = 144
    Top = 68
    ParamData = <
      item
        DataType = ftInteger
        Name = 've'
        ParamType = ptInput
        Value = nil
      end>
  end
  object UniConnection: TUniConnection
    ProviderName = 'Oracle'
    Options.DisconnectedMode = True
    Options.KeepDesignConnected = False
    Username = 'SYSTEM'
    Server = 'ORACLE_XE_LOCAL'
    LoginPrompt = False
    Left = 232
    Top = 68
    EncryptedPassword = 'ACFFA6FFACFFABFFBAFFB2FF'
  end
  object UniQuery1: TUniQuery
    Connection = UniConnection
    SQL.Strings = (
      'select * from ('
      ''
      'SELECT ID, VERSION, PRIORITY, CREATED FROM'
      'MO_TMP '
      ''
      ') order by CREATED')
    SpecificOptions.Strings = (
      'Oracle.FetchAll=True')
    Left = 232
    Top = 128
  end



PART OF MEMORY LEAK:

Code: Select all

--------------------------------2016/3/29 13:13:14--------------------------------
A memory block has been leaked. The size is: 4

This block was allocated by thread 0x17B4, and the stack trace (return addresses) at the time was:
406E5E [System.pas][System][@GetMem$qqri][4602]
6413EC [CLRClasses.pas][CLRClasses][Marshal.AllocHGlobal$qqri][427]
7E2958 [OraClassesUni][TOraTimeStamp.Init$qqrus]
7E28A9 [OraClassesUni][TOraTimeStamp.$bctr$qqrp21Oracalluni.TOCISvcCtxus]
7DE51B [OraClassesUni][TOCIRecordSet.FetchArray$qqro]
43759C [System.Variants.pas][System.Variants][Variants.VarClearDeep$qqrr8TVarData][830]
4375A1 [System.Variants.pas][System.Variants][Variants.VarClearDeep$qqrr8TVarData][830]
437632 [System.Variants.pas][System.Variants][Variants.@VarClear$qqrr8TVarData][881]
43763A [System.Variants.pas][System.Variants][Variants.@VarClr$qqrr8TVarData][900]
75199B [Uni.pas][Uni][TCustomUniDataSet.GetFetchAll$qqrv][3398]
7DCE43 [OraClassesUni][TOCIRecordSet.InternalFetch$qqro]

The block is currently used for an object of class: Unknown

The allocation number is: 5722

Current memory dump of 256 bytes starting at pointer address 7FDD6730:
00 00 5A 82 C1 7B 80 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 73 00 00
88 EF 82 00 00 00 00 00 70 48 DB 7F D0 2E DC 7F F0 6F DD 7F 00 00 00 00 00 00 00 00 F1 8A DD 7F
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 05 00 00 5E 6E 40 00 0F 9D 40 00 9C A1 40 00
2D C3 63 00 78 C2 63 00 96 AA 82 00 A8 97 40 00 14 98 40 00 4B F6 40 00 88 D6 82 00 F4 38 2B 76
B4 17 00 00 B4 17 00 00 C9 9D 40 00 B1 B7 40 00 F9 B6 40 00 F9 B7 40 00 DE BB 40 00 C3 C3 63 00
C1 C0 63 00 F7 7F 40 00 C6 AD 78 00 3C 97 40 00 45 9B 40 00 28 00 00 00 B0 04 02 00 43 19 A1 FC
.  .  Z  ‚  Á  {  €  €  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  6  s  .  .
ˆ  ï  ‚  .  .  .  .  .  p  H  Û    Ð  .  Ü    ð  o  Ý    .  .  .  .  .  .  .  .  ñ  Š  Ý  
.  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  €  .  .  .  ^  n  @  .  .    @  .  œ  ¡  @  .
-  Ã  c  .  x  Â  c  .  –  ª  ‚  .  ¨  —  @  .  .  ˜  @  .  K  ö  @  .  ˆ  Ö  ‚  .  ô  8  +  v
´  .  .  .  ´  .  .  .  É    @  .  ±  ·  @  .  ù  ¶  @  .  ù  ·  @  .  Þ  »  @  .  à  à  c  .
Á  À  c  .  ÷    @  .  Æ  ­  x  .  <  —  @  .  E  ›  @  .  (  .  .  .  °  .  .  .  C  .  ¡  ü

--------------------------------2016/3/29 13:13:14--------------------------------
This application has leaked memory. The small block leaks are (excluding expected leaks registered by pointer):

1 - 4 bytes: Unknown x 300
37 - 52 bytes: TOraTimeStamp x 150

Note: Memory leak detail is logged to a text file in the same folder as this application. To disable this memory leak check, undefine "EnableMemoryLeakReporting".

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: UniSQL Memory Leak (Oracle field: Timestamp)

Post by MaximG » Mon 04 Apr 2016 14:48

We have investigated UniDAC behavior on using Timestamp data types according to your source codes. Unfortunately, we couldn't detect memory leaks. For testing, we used FastMM 4 with option FullDebugMode and MadExcept 4.0.13 with options 'Report resource leaks' and 'Instantly crash on buffer'. For further investigation, please send us a sample project reproducing memory leak when working with the MO_TMP table.

Post Reply