使用oracle xmldb编写大型xmlfile时出现进程内存错误

时间:2013-12-22 11:17:19

标签: sql xml oracle oracle9i oracle-xml-db-repository

我们在使用oracle 9i的xmldb工具编写大型xml文件时遇到了问题。该查询生成大约300万行,oracle响应以下错误消息:

ERROR at line 1:
ORA-04030: out of process memory when trying to allocate 4012 bytes
(qmxtgCreateBuf,kghsseg: kolaslCreateCtx)
ORA-06512: at "....", line 1154
ORA-06512: at line 1
ERROR: 
ORA-00600: internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s],
[%s], [%s]

在警告日志中:

Errors in file d:/db/admin/acc1/udump/acc1_ora_8112.trc:
ORA-00600: internal error code, arguments: [729], [104], [space leak], [], [], [], [], []

我们已经尝试过增加进程内存,但这几乎没有任何影响。

有没有办法让oracle为xml使用更少的内存(一个'lazy manifestation'/ writethrough开关或类似的东西?

1 个答案:

答案 0 :(得分:2)

您需要使用BULK操作和LIMITED PAGED查询来管理流程消耗的内存 例如:

DECLARE
  CURSOR c_customer IS
    SELECT CUSTOMER.id, CUSTOMER.name from CUSTOMER;
  TYPE customer_array_type IS TABLE OF c_customer%ROWTYPE INDEX BY BINARY_INTEGER;
  customer_array customer_array_type;
  fetch_size     NUMBER := 5000; -- scale the value to manage memory
BEGIN
  -- Open(create) XML file
  OPEN c_customer;
  loop
    FETCH c_customer BULK COLLECT
      INTO customer_array LIMIT fetch_size;
    FOR i IN 1 .. customer_array.COUNT LOOP
      null; -- Add XML nodes
    END LOOP;
    EXIT WHEN c_customer%NOTFOUND;
  END LOOP;
  CLOSE c_customer;
  -- Close(flush) XML file
End;

在某些情况下,当文件大小超过操作系统文件大小限制时,您必须创建多个文件。