Memory usage with Oracle VARCHAR(4000 Byte) and Long String

General discussion forum about all databases other than SqlBase.
pba

Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by pba » 14 Oct 2014, 14:34

Hello!

An executable (win32) which loads an VARCHAR(4000 Byte) into a Long String variable uses different memory either if it runs in TD Developer environment or in TD runtime environment.
In our customer real world application the difference we get an out of memory error.

Example:
I built a small executable which connects to a Oracle database and loads

SELECT LRT_VARCHAR4000 FROM LONGSTRINGTEST INTO :l_lsLong

a record with an empty VARCHAR(4000 Byte) field (LRT_VARCHAR4000 VARCHAR2(4000 BYTE)).

When I run the LongString executable in TD Developer environment in task manager I can see it uses about 51MB.
LongStringTD_DevelopmentEnvironment.jpg
When I run the LongString executable in TD Runtime environment in task manager I can see it uses about 139MB.
LongStringTD_RunTimeEnvironment.jpg
That is a very high difference for such small data.

Can anybody reproduce this behavior or explain it?
Has anybody noticed similar behavior yet?

Please find attached the sample program and a script to create the database table.

Thank you!
Peter Bars
Entimo AG
You do not have the required permissions to view the files attached to this post.

User avatar
markus.essmayr
Austria
Posts: 892
Joined: 06 Mar 2017, 06:07
Location: Austria

Re: Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by markus.essmayr » 15 Oct 2014, 06:44

Hi,

just to understand it:

"TD Development Environment" is a machine, where the TD IDE is installed.
"TD Runtime Environment" is a machine, where only the TD runtime is installed.

Is that correct?
I suppose, both the TD IDE and the TD runtime are completely the same Version (Service Pack, Hot Fixes).
And also your Oracle Client files have to be the same Version!

Could you please run your sample application in both environments.
After the application loaded your 4k string, Launch Process Explorer (http://technet.microsoft.com/en-us/sysi ... s/bb896653) and explore the list of loaded modules. Are there any differences?

Max
Markus Eßmayr
teamdeveloper@t-mx.com

pba

Re: Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by pba » 15 Oct 2014, 09:55

Hi lrcuess,

First of all thank you for your recommendation.

Yes, you are right
"TD Development Environment" is a machine, where the TD IDE is installed and
"TD Runtime Environment" is a machine, where only the TD runtime is installed.

With the process explorer I checked the used dll’s, its versions and its memory use.
As you can see in the attached excel file “LongString.DLL.use.xlsx” :
  • the loaded dll’s are the same,
  • the versions are the same and
  • even the memory usage is (almost) the same.
I created screenshots of the process properties in the process explorer as additional information.
In the pictures you can see differences in section Physical Memory.
LongStringRuntime_Properties.jpg
LongStringIDE_Properties.jpg
Does anybody have any idea?

Thank you!
Peter Bars
Entimo AG
You do not have the required permissions to view the files attached to this post.

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3352
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by Dave Rabelink » 15 Oct 2014, 10:25

Try to run both situations on the same machine.

Copy the TDRuntime folder and your application exe/dll's into one folder and place it on the same machine the TD IDE is installed.
Run your application from that folder.

Is there a difference then?
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

pba

Re: Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by pba » 15 Oct 2014, 10:46

Hi Dave,

I have already done it before I send the post above.
On the same machine I can reproduce the results of the different machines.

Regards,
Peter Bars

User avatar
markus.essmayr
Austria
Posts: 892
Joined: 06 Mar 2017, 06:07
Location: Austria

Re: Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by markus.essmayr » 15 Oct 2014, 10:57

In your TD developer environment: Is the TD IDE running, when your measure the memory usage?
In your TD runtime environment: What happens if you run your sample application multiple times in parallel (keep the previous instances running when launching another)?

Max
Markus Eßmayr
teamdeveloper@t-mx.com

pba

Re: Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by pba » 15 Oct 2014, 11:16

In your TD developer environment: Is the TD IDE running, when your measure the memory usage?
No, the IDE does not run.
In your TD runtime environment: What happens if you run your sample application multiple times in parallel (keep the previous instances running when launching another)?
When I launch more instances and keep them running, each instance has almost the same memory usage.


On the same machine:
the instances launching from the IDE have the low memory useage,
the instances launching from the runtime have the heigh memory useage.

Thank you!

User avatar
markus.essmayr
Austria
Posts: 892
Joined: 06 Mar 2017, 06:07
Location: Austria

Re: Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by markus.essmayr » 15 Oct 2014, 11:23

Just to give it a try:
Make a backup of your TD IDE installation directory.
Copy alle files from the runtime directory into your IDE directory.
Launch the IDE and run your sample application.

High or low memory usage?

Max
Markus Eßmayr
teamdeveloper@t-mx.com

pba

Re: Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by pba » 15 Oct 2014, 11:49

Copy alle files from the runtime directory into your IDE directory
Low memory usage!


Peter

pba

Re: Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by pba » 16 Oct 2014, 08:03

Hi all,

thank you for your tips.

Disconnecting the sql handel decreases the memory use to an normal level.

The real problem is, loading a 4K string consumes about 80MB memory (even the string is empty).

In our customer application we have in one SQL statement 3 of such strings. The memory use really increases about 3 times 80MB. One instance of the program uses over 300MB memory.

For that I’m still looking for a solution.

Peter

User avatar
markus.essmayr
Austria
Posts: 892
Joined: 06 Mar 2017, 06:07
Location: Austria

Re: Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by markus.essmayr » 16 Oct 2014, 08:17

Did you ever try to use another database to compare memory consumption?
I know this doesn't solve your problem but maybe it helps to understand the problem cause.

Max
Markus Eßmayr
teamdeveloper@t-mx.com

pba

Re: Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by pba » 16 Oct 2014, 09:25

Hi all,

I got it.

Both installations uses different sql.ini files.
In the IDE uses a sql.ini with variable longbuffer=10000000.
In the Runtime uses a sql.ini with variable longbuffer=100000000.

We need this high value to store files in the database.

Does anybody know a maximum value of longbuffer?

Thank you for help and sorry for that.

Peter

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3352
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: Memory usage with Oracle VARCHAR(4000 Byte) and Long String

Post by Dave Rabelink » 16 Oct 2014, 14:14

Programmatically set the longbuffer size and keep the SQL.ini setting low.

First get the current setting:

Code: Select all

Call SqlGetParameterAll ( hSqlConnect, SQLPLBUF, nInitialBufferLength, sDummy, TRUE )
Calculate the needed buffer length and do

Code: Select all

Call SqlSetParameterAll ( hSqlConnect, SQLPLBUF, nBufferLength, STRING_Null, TRUE )
Set the initial value back after use.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests