Loadfromfile slow as Windows Service

Halli

Member
Hi,
I've created a Windows Service in Delphi XE7 on my Windows 7 machine. The service converts docx to pdf like this:

a) connects to oracle and checks if docx need to be converted
b) finds a single docx and loads from database with:
m_BLOB := TOracleQuery.LOBField('BFile');
m_BLOB.SaveToFile(strFullPath);
c) then uses Word to open that file and save as pdf:
FWordApp := CreateOleObject('Word.Application');
FWordDoc := FWordApp.documents.open(strFullPathFiledoc,0,0);
FWordDoc.saveas(strFullPathFilepdf,17);
d) Now TLoblocator opens this pdf-file:

m_LOB := TLOBLocator.CreateTemporary(pSession, otBLOB, false );
LogMessage(datetimetostr(Now) + ' TService 1 LoadFromFile' , EVENTLOG_INFORMATION_TYPE, 0, 2);
m_LOB.LoadFromFile(strFullPath);
LogMessage(datetimetostr(Now) + ' TService 2 LoadFromFile' , EVENTLOG_INFORMATION_TYPE, 0, 2); // takes 6 sec

e) Sends m_LOB to the database

The Event viewer shows me that the last bit: loadfromfile takes
within one second on my local machine.
But when I move the service on to another machine, Windows 8,
the loadfromfile in d) takes 6 seconds, and that is not acceptable.

Have you any ideas on how to fix this?
My service on the "server" machine (windows 8) is running as an admin user.

The word-command in c) is doing a similar thing:

FWordDoc := FWordApp.documents.open(strFullPathFiledoc,0,0);
and that runs within 1 sec !

kind regards, Halli
 
Last edited:
As a test, what happens if you load the file into a TMemoryStream and then copy the TMemoryStream to the TLOBLocator? What is the performance of these 2 steps?
 
Hi, thank you for your response. I tried:

var
m_LOB: TLOBLocator;
m_LOBStream : TMemoryStream;
begin
m_LOB := TLOBLocator.CreateTemporary(pKerfi.Session, otBLOB, false );
m_LOBStream := TMemoryStream.Create;
LogMessage(datetimetostr(Now) + ' TSkjalakerfi_service_doc_to_pdf TMemoryStream LoadFromFile ' , EVENTLOG_INFORMATION_TYPE, 0, 2);
m_LOBStream.LoadFromFile( strFullPath );
m_LOB.CopyFrom( m_LOBStream, m_LOBStream.Size);
LogMessage(datetimetostr(Now) + ' TSkjalakerfi_service_doc_to_pdf TMemoryStream LoadFromFile lokid', EVENTLOG_INFORMATION_TYPE, 0, 2);

...and it took 5 sec :(
 
Last edited:
Hi,
I ran this code just now:

m_LOB := TLOBLocator.CreateTemporary(pKerfi.Session, otBLOB, false );
m_LOBStream := TMemoryStream.Create;
LogMessage(datetimetostr(Now) + ' TSkjalakerfi_service_doc_to_pdf TMemoryStream A LoadFromFile' , EVENTLOG_INFORMATION_TYPE, 0, 2);
m_LOBStream.LoadFromFile( strFullPath );
LogMessage(datetimetostr(Now) + ' TSkjalakerfi_service_doc_to_pdf TMemoryStream B CopyFrom' , EVENTLOG_INFORMATION_TYPE, 0, 2);
m_LOB.CopyFrom( m_LOBStream, m_LOBStream.Size);
LogMessage(datetimetostr(Now) + ' TSkjalakerfi_service_doc_to_pdf TMemoryStream C CopyFrom END' , EVENTLOG_INFORMATION_TYPE, 0, 2);


and it seems that the

m_LOB.CopyFrom( m_LOBStream, m_LOBStream.Size);

...takes 6 sec.

Then, instead of CopyFrom i tried:

m_lob.Write( m_LOBStream.Memory^, m_LOBStream.Size);

but with same results: it took 6 sec. to run.
 
Last edited:
The reason why Im trying to put my blob file into TLoblocator is because later Im using this procedure:

procedure TSkjBrefKerfi.SkjBrefUppfaeraBlob(PBrefNnr: Double; PBlob: TLOBLocator;
const PMime: string);
begin
GetQuery;
OCPQuery.DeclareVariable('P_BREF_NNR', otFloat);
OCPQuery.SetVariable('P_BREF_NNR', PBrefNnr);
OCPQuery.DeclareVariable('P_BLOB', otBLOB);
OCPQuery.SetComplexVariable('P_BLOB', PBlob);
OCPQuery.DeclareVariable('P_MIME', otString);
OCPQuery.SetVariable('P_MIME', PMime);
OCPQuery.SQL.Add('begin');
OCPQuery.SQL.Add(' "SUPERVISOR"."SKJ_BREF_KERFI"."SKJ_BREF_UPPFAERA_BLOB"(');
OCPQuery.SQL.Add(' P_BREF_NNR => :P_BREF_NNR,');
OCPQuery.SQL.Add(' P_BLOB => :P_BLOB,');
OCPQuery.SQL.Add(' P_MIME => :P_MIME);');
OCPQuery.SQL.Add('end;');
OCPQuery.Execute;
end;
 
Hi,
No, setting the param to true:

m_LOB := TLOBLocator.CreateTemporary(pKerfi.Session, otBLOB, true );

does not change much... this command:

m_lob.Write( m_LOBStream.Memory^, m_LOBStream.Size);

still takes 4 to 6 sec to finish.

Do you think that increasing the memory on the server computer will help?

regards, Haraldur
 
You could try that. You can also try to disable virus scanners and/or spam filters on the Windows 7 PC, or try it on a different PC, or on the server itself (if it is a Windows Server). Maybe you can find a clue what the cause of the problem is: the local PC, the network, or the server.
 
Back
Top