Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Oracle Instant Client and PHP memory leak(s)

557199Jan 3 2008 — edited Jan 25 2008
So recently we ran into a rather interesting problem. One of our developers was writing an import script that would import data into Oracle 10g database and he noticed that his script would slowly eat more and more memory as it did the import. I spent some time investigating and after creating a very basic PHP script and running it from the command-line through valgrind it seems that Oracle Instanct Client library is leaking memory.

Operating System: linux (Mandriva 2008) - 32 bit
PHP: 5.2.4
Oracle Instant Client: 10.2.0.3 (and then upgraded to 11.1.0.1) using Oracle provided RPMS.
OCI8 extension: 1.2.4 (taken from PECL)
Sample Script:

<?php
print "PHP Stress Test!\n";

$conn = oci_connect('scott', 'tiger', 'xxxxx');

for ($i = 1; $i < 100; $i++) {
print "#$i: " . memory_get_usage() . "\n";

$s = oci_parse($conn, "SELECT 1 FROM dual");
oci_execute($s);
$r = oci_fetch_row($s);
oci_free_statement($s);
}
?>

ran valgrind with the following options:
valgrind tool=memcheck show-reachable=yes --leak-check=full php stress.php 2>valgrind.dump

also for this script it seems that as far as PHP is concerned memory is not being leaked, but valgrind produces a file of about 350k.

P.S. I just upgarded to 11.1.0.1 using the Oracle provided Linux x86 RPMS and it seems that I can't use basiclite since sqlplus and dev packages require basic.

Gena01

Comments

Chaitanya.S.S.K
try:

insert into <table_with_no_data> select * from <table_with_data>;
602093

Yes Chaitanya thats correct, example:

SQL> create table emp_j as select * from emp where 1=2;

Table created.

SQL> desc emp_j;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 EMPID                                              NUMBER
 EMPNAME                                            VARCHAR2(20)
 AGE                                                NUMBER
 SALARY                                             NUMBER
 DEPTID                                             NUMBER
 MGRID                                              NUMBER

SQL> select count(*) from emp;

  COUNT(*)
----------
        11

SQL> select count(*) from emp_j;

  COUNT(*)
----------
         0

SQL> insert into emp_j select * from emp;

11 rows created.

SQL> select * from emp;

     EMPID EMPNAME                     AGE     SALARY     DEPTID      MGRID
---------- -------------------- ---------- ---------- ---------- ----------
        34 TEST                         87    3453453          4
         1 RAMESH                       32      35000
         2 VIKAS                        23      22000
         3 RAJ                          35     500000          4          1
         4 RAKESH                       25      29000          1
         5 VIJAY                        30      31000          3
         6 KASHYAP                      28      28000          6
         7 TOM                          26      25000          5
         8 MAHESH                       24      22000          4
         9 PREM                         27      27000
        10 SRINIVAS                     42      54000          3

11 rows selected.
619823
well .. i hv tried this .. it works but why 1=2 at the end..the statement works even without this..
210640
Because that create table command is just to create table without copying data.
I think in your question, you said you want to copy data from another table with same structure. Thus why Jith created an empty table with the same structure.

HTH
SHY
618702
beware of constraints while creating the copy table.
creation will create only NOT NULL constraints. primary key, foreing key and unique constraints will not be created with this query:"create table copy_trial as select * from trial;"
fsze88hoho
Dear Jith

I want to know will it possible to copy the data from another schema?
It may great help for me.
insert into emp_j select * from emp;

:>
Francis
RadhakrishnaSarma
By "copy data from schema", you mean table by table? Of course it is possible, if you have permissions on the other schema table.
insert into my_table
select * 
from other_schema.table
Cheers
Sarma.
fsze88hoho
Dear Sarma

How about copy data from one schema to another schema, which they are different Server(computer)?

Will it be possible?

Thanks a lot :>
623107
Yes you can do it by create a db link (database link)
then write query like

insert into my_table
select *
from other_schema.table@(db link name)

Regards
asif
608922
You need to have corresponding object privileges to do the same when you are trying to copy data from the table of another schema or another database.

Create a private database link in case if you want ti copy data from another database
460544
With similar table structure you can copy data from one schema to another
schema
login to target database1


Condition1 Append data
copy from scott/tiger@database2 append emp using select * from emp;

Condition2 create new table
copy from scott/tiger@database2 create emp using select * from emp;
1 - 11
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Feb 22 2008
Added on Jan 3 2008
2 comments
3,185 views