Issue 11314 - Memory usage when i put value in XCell
Summary: Memory usage when i put value in XCell
Status: CLOSED WONT_FIX
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC Windows 2000
: P3 Trivial
Target Milestone: ---
Assignee: cdufeutrelle
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-08 10:04 UTC by cdufeutrelle
Modified: 2013-02-24 21:08 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description cdufeutrelle 2003-02-08 10:04:35 UTC
Language : Delphi 5 and OO API 
I plan to use OpenOffice for reporting under delphi.
With your doc. (Staroffice Programmer's Tutorial - StarOffice and PDF) i write 
this functions :

function TStarOffice.SheetGetCellContent(nSheet,nCol,nRow : longint) : Variant;
var
 oSheets,oSheet,oCell : Variant;
 ret : variant;
begin
 oSheets := Document.Sheets;
 oSheet := oSheets.GetByIndex(nSheet);
 oCell := oSheet.GetCellByPosition (nCol,nRow);
 ret := '';
 case oCell.type of
  0 : result := varastype (ret,varnull);
  1 : result := oCell.Value;
  2 : result := oCell.String;
  3 : result := oCell.FormulaLocal;
 end;

end;

procedure TStarOffice.SheetPutCellContent(nSheet,nCol,nRow : longint;Value : 
Variant);
var
 oSheets,oSheet,oCell : Variant;
begin
 oSheets := Document.Sheets;
 oSheet := oSheets.GetByIndex(nSheet);
 oCell := oSheet.GetCellByPosition (nCol,nRow);
 if Vartype (Value) < 7 then
  oCell.Value := Value
 else
  oCell.String := Value
end;

I write a burn test for see if i can use many times this function so afert, OLE 
connection and create sheet document i do :

procedure TOKBottomDlg.Button4Click(Sender: TObject);
var
 i : longword;
begin
 StopBurnTest := False;
 i := 0;
 while (i < 4294967295) and not StopBurnTest do
 begin
   sample.SheetPutCellContent(0,0,0,i);
   sample.SheetPutCellContent(0,0,1,i);
   sample.SheetPutCellContent(0,0,2,i);
   if i mod 10 = 0 then
    StatusBar1.SimpleText := 'Loop : ' + inttostr(i);
   application.processmessages;
   inc(i);
 end;
end;

The problem is that OpenOffice eat on every loop x kb of ram (100 loops = 6600 
Kb see under the Win2000 task manager ), and when i close the delphi program 
and the sheet, the used memory dont down. The way is to quit the openoffice 
from the trayicon. This exemple is take from the documentation.
Comment 1 ooo 2003-02-10 08:30:29 UTC
implementation issue
Comment 2 niklas.nebel 2003-02-13 17:31:33 UTC
Looks more like a problem with the OLE bridge. Doing the same in Java
doesn't have those problems.
Comment 3 cdufeutrelle 2003-02-13 23:02:48 UTC
a test with the "openoffice delphi example" give the same problem. 
each click on the "get cell content" take some memory (16 to 20 kb).
Comment 4 joachim.lingner 2003-02-18 16:57:59 UTC
According to christophe dufeutrelle the problem should also occur 
when one put the loop into a VBScript. I stripped down the WriterDemo 
example:
'The service manager is always the starting point
'If there is no office running then an office is started up
Set objServiceManager= WScript.CreateObject
("com.sun.star.ServiceManager")

'Create the Desktop
Set objDesktop= objServiceManager.createInstance
("com.sun.star.frame.Desktop")

'Open a new empty writer document
Dim args()
Set objDocument= objDesktop.loadComponentFromURL
("private:factory/swriter", "_blank", 0, args)

'Create a text object
Set objText= objDocument.getText

'Create a cursor object
Set objCursor= objText.createTextCursor

'Create instance of a text table with 4 columns and 4 rows
Set objTable= objDocument.createInstance
( "com.sun.star.text.TextTable")
objTable.initialize 2, 4

'Insert the table
objText.insertTextContent objCursor, objTable, false


For I = 1 To 10000
Set oCell= objTable.getCellByName("A2")
oCell.Value= i
Next

I used a new olebrdg.dll which can be obtained from 
www.openoffice.org and contains a fix for a memory leak. The script 
opens a new document creates a table and puts a value into a cell. 
After the script finished, I closed it with and run the script again. 
The memory usage was taken from the task manager on windows XP. The 
values are:

19340
19376
19564
19732
19916

When I did not set the value then the results were:
For I = 1 To 10000
Set oCell= objTable.getCellByName("A2")
'oCell.Value= i
Next

31040
31148
31172
31316
31348

It seemed that the value only increased because a new document was 
opend. The continuing getCellByName call does not seem to have an 
impact on memory consumption. 










Comment 5 joachim.lingner 2003-02-19 10:47:01 UTC
I also checked the VB script on Windows 2000. The new document window 
was closed and the originaly window was minimized after the script 
was finished the results are:

2. 15168 kb
3. 15196 kb
4. 15936 kb

The first run resulted in far more memory consumption, so I left it 
out. 
All these test show that the memory consumption is far less than the 
one christophe measured. According to him memory usage should 
increase by 60MB with a loop that iterates 10000 times. Therefore 
this bug could not be confirmed.

There are several reasons why the office seems to need more and more 
memory during its lifetime. Memory leaks could be one reason but it 
also caches data( e.g. undo, etc.). Also, the client program could 
belatedly release objects. This could only be ruled out if the client 
is written in C++ where one has explicit control about object 
references. But then, there is still COM involved, which has to 
construct stub objects in the office process which dispatch calls to 
the actual objects.
Another point is memory fragmentation which can cause an ever 
increasing memory usage.
Our test were performed with vbs as client, because there was no 
Delphi available. This may also add to different results.
In all, our tests could not confirm this issue. Therefore the bug 
will be closed.
Comment 6 joachim.lingner 2003-02-19 10:50:32 UTC
Will not fix
Comment 7 michael.bemmer 2003-03-11 18:06:49 UTC
As mentioned on the qa dev list on March 5th I will close all resolved duplicate
issues. Please see this posting for details. First step in IssueZilla is
unfortunately to set them to verified.
Comment 8 michael.bemmer 2003-03-11 18:15:05 UTC
As mentioned on the qa dev list on March 5th I will close all resolved
<wontfix/duplicate/worksforme/invalid> issues. Please see this posting for details.