PHP-memory leak with COM-objects?

PHP-memory leak with COM-objects?

am 10.10.2007 09:36:00 von Gustav Wiberg

Hi!
=20
I want to use COM+ objects (especially with Word). I have understood (a lot=
of reading on the Internet) that when initiating COM-objects with Word (ev=
en if the object is released in variable in the code). Word leaks a lot of =
memory. I have also read that if I want to use Word-COM+ object I should ha=
ve a dedicated server because it takes so much memory.
=20
I have tested some and I easily get out of memory even if there is 4GB on t=
he server I tested against.=20
=20
Then I run PHP as ISAPI, and the suggestion on the php.net site was to run =
PHP as CGI because COM-objects are run in the same memory-space as ISAPI wh=
en running as ISAPI-module. http://php.oregonstate.edu/manual/en/class.com.=
php
=20
=20
=20
What do you guys thinks about above? Give me some feedback, please :-)
=20
Best regards
/Gustav Wiberg
=20

No virus found in this outgoing message.
Checked by AVG Free Edition.=20
Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date: 2007-10-09=
16:43
=20

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-memory leak with COM-objects?

am 10.10.2007 13:30:56 von John Mertic

I've worked a lot with the Word COM and while it works well on a
single desktop, I wouldn't recommend it for a server process. It's
rather slow and while the memory eventually gets cleaned up, it still
takes up a lot of memory for as little as it does. I'm not so sure
OpenOffice is much better in this regard.

You could push these tasks to another server, but I'd also look at
what you are doing and see if you can do it another way. We currently
use Word documents as template for a mail merge type operation and are
looking to move these to RTF since that enables us to take Word out of
the loop when doing the mail merge ( we actually just do a global find
and replace in the document since we've found more consistent results
with that ). But again, this all depends upon the application.

John

On 10/10/07, Gustav Wiberg wrote:
> Hi!
>
> I want to use COM+ objects (especially with Word). I have understood (a lot of reading on the Internet) that when initiating COM-objects with Word (even if the object is released in variable in the code). Word leaks a lot of memory. I have also read that if I want to use Word-COM+ object I should have a dedicated server because it takes so much memory.
>
> I have tested some and I easily get out of memory even if there is 4GB on the server I tested against.
>
> Then I run PHP as ISAPI, and the suggestion on the php.net site was to run PHP as CGI because COM-objects are run in the same memory-space as ISAPI when running as ISAPI-module. http://php.oregonstate.edu/manual/en/class.com.php
>
>
>
> What do you guys thinks about above? Give me some feedback, please :-)
>
> Best regards
> /Gustav Wiberg
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date: 2007-10-09 16:43
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
John Mertic
jmertic@gmail.com
http://jmertic.wordpress.com

"Explaining a joke is like dissecting a frog: you understand it
better, but the frog dies
in the process." --Mark Twain

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-memory leak with COM-objects?

am 10.10.2007 15:06:41 von Trevor Gryffyn

One thing to watch out for with using COM objects is to make sure you
actually close the application when you're done using it and/or don't end
up opening multiple instances of the application.

I can't remember what the exactly sequence was, but I think it was either
Application.Exit() or Application.Quit() (or both?). I think the
Application.Close() method just closes the document and not the application
and.. again going on memory here... I believe the default state of the
application was Visible = False, so you wouldn't even see that the
application is still running unless you pulled up the Task Manager.

I don't know anything about memory leaks with this process, just know that
this is one big "gotcha" that can eat up a ton of CPU and memory resources.
For me, COM is a last resort. It's bulky and ugly and has a lot of
potential for things like memory leaks and system instability in general.
You might look to see if there's a PEAR package that can do what you want
to do without using Word directly.

-TG

----- Original Message -----
From: Gustav Wiberg
To: 'PHP-Windows Group'
Date: Wed, 10 Oct 2007 09:36:00 +0200
Subject: [PHP-WIN] PHP-memory leak with COM-objects?

> Hi!
>
> I want to use COM+ objects (especially with Word). I have understood (a lot
> of reading on the Internet) that when initiating COM-objects with Word
> (even if the object is released in variable in the code). Word leaks a
> lot of memory. I have also read that if I want to use Word-COM+ object I
> should have a dedicated server because it takes so much memory.
>
> I have tested some and I easily get out of memory even if there is 4GB on
> the server I tested against.
>
> Then I run PHP as ISAPI, and the suggestion on the php.net site was to run
> PHP as CGI because COM-objects are run in the same memory-space as ISAPI
> when running as ISAPI-module.
> http://php.oregonstate.edu/manual/en/class.com.php
>
>
>
> What do you guys thinks about above? Give me some feedback, please :-)
>
> Best regards
> /Gustav Wiberg
>
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date: 2007-10-09
> 16:43
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-memory leak with COM-objects?

am 10.10.2007 19:30:48 von Gustav Wiberg

Hi again!

I want the logged-in user to able to open a word-file (or an Excel-file or
whatever) and then Push Save-Icon and make sure that changes are actually
made.
Example:

John opens up file c:\test.doc. He writes "Ugly cow" in it and pushes the
save-icon. Ugly Cow is now stored in file c:\test.doc. Working with
COM-objects is the only solution I have found!?

Normally If John opens up c:\test.doc Internet Explorer (or whatever
browser) saves the file temporarily in some temp-folder (don't know exact
location), lets say c:\temp\sdifiuweoriu2734872.tmp. When John pushes
Save-icon he saves the new information TO the temporarily stored file IF he
doesn't use Save AS...

Please come with suggestions :-)

Best regards
/Gustav Wiberg

----- Original Message -----
From: "John Mertic"
To: "Gustav Wiberg"
Cc: "PHP-Windows Group"
Sent: Wednesday, October 10, 2007 1:30 PM
Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?


> I've worked a lot with the Word COM and while it works well on a
> single desktop, I wouldn't recommend it for a server process. It's
> rather slow and while the memory eventually gets cleaned up, it still
> takes up a lot of memory for as little as it does. I'm not so sure
> OpenOffice is much better in this regard.
>
> You could push these tasks to another server, but I'd also look at
> what you are doing and see if you can do it another way. We currently
> use Word documents as template for a mail merge type operation and are
> looking to move these to RTF since that enables us to take Word out of
> the loop when doing the mail merge ( we actually just do a global find
> and replace in the document since we've found more consistent results
> with that ). But again, this all depends upon the application.
>
> John
>
> On 10/10/07, Gustav Wiberg wrote:
>> Hi!
>>
>> I want to use COM+ objects (especially with Word). I have understood (a
>> lot of reading on the Internet) that when initiating COM-objects with
>> Word (even if the object is released in variable in the code). Word leaks
>> a lot of memory. I have also read that if I want to use Word-COM+ object
>> I should have a dedicated server because it takes so much memory.
>>
>> I have tested some and I easily get out of memory even if there is 4GB on
>> the server I tested against.
>>
>> Then I run PHP as ISAPI, and the suggestion on the php.net site was to
>> run PHP as CGI because COM-objects are run in the same memory-space as
>> ISAPI when running as ISAPI-module.
>> http://php.oregonstate.edu/manual/en/class.com.php
>>
>>
>>
>> What do you guys thinks about above? Give me some feedback, please :-)
>>
>> Best regards
>> /Gustav Wiberg
>>
>>
>> No virus found in this outgoing message.
>> Checked by AVG Free Edition.
>> Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date:
>> 2007-10-09 16:43
>>
>>
>> --
>> PHP Windows Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> John Mertic
> jmertic@gmail.com
> http://jmertic.wordpress.com
>
> "Explaining a joke is like dissecting a frog: you understand it
> better, but the frog dies
> in the process." --Mark Twain
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-memory leak with COM-objects?

am 10.10.2007 19:55:54 von John Mertic

Is c:\test.doc a file on the local user's machine or the server?

On 10/10/07, Gustav Wiberg wrote:
> Hi again!
>
> I want the logged-in user to able to open a word-file (or an Excel-file or
> whatever) and then Push Save-Icon and make sure that changes are actually
> made.
> Example:
>
> John opens up file c:\test.doc. He writes "Ugly cow" in it and pushes the
> save-icon. Ugly Cow is now stored in file c:\test.doc. Working with
> COM-objects is the only solution I have found!?
>
> Normally If John opens up c:\test.doc Internet Explorer (or whatever
> browser) saves the file temporarily in some temp-folder (don't know exact
> location), lets say c:\temp\sdifiuweoriu2734872.tmp. When John pushes
> Save-icon he saves the new information TO the temporarily stored file IF he
> doesn't use Save AS...
>
> Please come with suggestions :-)
>
> Best regards
> /Gustav Wiberg
>
> ----- Original Message -----
> From: "John Mertic"
> To: "Gustav Wiberg"
> Cc: "PHP-Windows Group"
> Sent: Wednesday, October 10, 2007 1:30 PM
> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
>
>
> > I've worked a lot with the Word COM and while it works well on a
> > single desktop, I wouldn't recommend it for a server process. It's
> > rather slow and while the memory eventually gets cleaned up, it still
> > takes up a lot of memory for as little as it does. I'm not so sure
> > OpenOffice is much better in this regard.
> >
> > You could push these tasks to another server, but I'd also look at
> > what you are doing and see if you can do it another way. We currently
> > use Word documents as template for a mail merge type operation and are
> > looking to move these to RTF since that enables us to take Word out of
> > the loop when doing the mail merge ( we actually just do a global find
> > and replace in the document since we've found more consistent results
> > with that ). But again, this all depends upon the application.
> >
> > John
> >
> > On 10/10/07, Gustav Wiberg wrote:
> >> Hi!
> >>
> >> I want to use COM+ objects (especially with Word). I have understood (a
> >> lot of reading on the Internet) that when initiating COM-objects with
> >> Word (even if the object is released in variable in the code). Word leaks
> >> a lot of memory. I have also read that if I want to use Word-COM+ object
> >> I should have a dedicated server because it takes so much memory.
> >>
> >> I have tested some and I easily get out of memory even if there is 4GB on
> >> the server I tested against.
> >>
> >> Then I run PHP as ISAPI, and the suggestion on the php.net site was to
> >> run PHP as CGI because COM-objects are run in the same memory-space as
> >> ISAPI when running as ISAPI-module.
> >> http://php.oregonstate.edu/manual/en/class.com.php
> >>
> >>
> >>
> >> What do you guys thinks about above? Give me some feedback, please :-)
> >>
> >> Best regards
> >> /Gustav Wiberg
> >>
> >>
> >> No virus found in this outgoing message.
> >> Checked by AVG Free Edition.
> >> Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date:
> >> 2007-10-09 16:43
> >>
> >>
> >> --
> >> PHP Windows Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> >
> > --
> > John Mertic
> > jmertic@gmail.com
> > http://jmertic.wordpress.com
> >
> > "Explaining a joke is like dissecting a frog: you understand it
> > better, but the frog dies
> > in the process." --Mark Twain
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
>


--
John Mertic
jmertic@gmail.com
http://jmertic.wordpress.com

"Explaining a joke is like dissecting a frog: you understand it
better, but the frog dies
in the process." --Mark Twain

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-memory leak with COM-objects?

am 10.10.2007 21:28:46 von Gustav Wiberg

Hi!

It was just an example, but say Yes. Does it make a difference?

Best regards
/Gustav Wiberg

----- Original Message -----
From: "John Mertic"
To: "Gustav Wiberg"
Cc: "PHP-Windows Group"
Sent: Wednesday, October 10, 2007 7:55 PM
Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?


> Is c:\test.doc a file on the local user's machine or the server?
>
> On 10/10/07, Gustav Wiberg wrote:
>> Hi again!
>>
>> I want the logged-in user to able to open a word-file (or an Excel-file
>> or
>> whatever) and then Push Save-Icon and make sure that changes are actually
>> made.
>> Example:
>>
>> John opens up file c:\test.doc. He writes "Ugly cow" in it and pushes the
>> save-icon. Ugly Cow is now stored in file c:\test.doc. Working with
>> COM-objects is the only solution I have found!?
>>
>> Normally If John opens up c:\test.doc Internet Explorer (or whatever
>> browser) saves the file temporarily in some temp-folder (don't know exact
>> location), lets say c:\temp\sdifiuweoriu2734872.tmp. When John pushes
>> Save-icon he saves the new information TO the temporarily stored file IF
>> he
>> doesn't use Save AS...
>>
>> Please come with suggestions :-)
>>
>> Best regards
>> /Gustav Wiberg
>>
>> ----- Original Message -----
>> From: "John Mertic"
>> To: "Gustav Wiberg"
>> Cc: "PHP-Windows Group"
>> Sent: Wednesday, October 10, 2007 1:30 PM
>> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
>>
>>
>> > I've worked a lot with the Word COM and while it works well on a
>> > single desktop, I wouldn't recommend it for a server process. It's
>> > rather slow and while the memory eventually gets cleaned up, it still
>> > takes up a lot of memory for as little as it does. I'm not so sure
>> > OpenOffice is much better in this regard.
>> >
>> > You could push these tasks to another server, but I'd also look at
>> > what you are doing and see if you can do it another way. We currently
>> > use Word documents as template for a mail merge type operation and are
>> > looking to move these to RTF since that enables us to take Word out of
>> > the loop when doing the mail merge ( we actually just do a global find
>> > and replace in the document since we've found more consistent results
>> > with that ). But again, this all depends upon the application.
>> >
>> > John
>> >
>> > On 10/10/07, Gustav Wiberg wrote:
>> >> Hi!
>> >>
>> >> I want to use COM+ objects (especially with Word). I have understood
>> >> (a
>> >> lot of reading on the Internet) that when initiating COM-objects with
>> >> Word (even if the object is released in variable in the code). Word
>> >> leaks
>> >> a lot of memory. I have also read that if I want to use Word-COM+
>> >> object
>> >> I should have a dedicated server because it takes so much memory.
>> >>
>> >> I have tested some and I easily get out of memory even if there is 4GB
>> >> on
>> >> the server I tested against.
>> >>
>> >> Then I run PHP as ISAPI, and the suggestion on the php.net site was to
>> >> run PHP as CGI because COM-objects are run in the same memory-space as
>> >> ISAPI when running as ISAPI-module.
>> >> http://php.oregonstate.edu/manual/en/class.com.php
>> >>
>> >>
>> >>
>> >> What do you guys thinks about above? Give me some feedback, please :-)
>> >>
>> >> Best regards
>> >> /Gustav Wiberg
>> >>
>> >>
>> >> No virus found in this outgoing message.
>> >> Checked by AVG Free Edition.
>> >> Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date:
>> >> 2007-10-09 16:43
>> >>
>> >>
>> >> --
>> >> PHP Windows Mailing List (http://www.php.net/)
>> >> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>
>> >>
>> >
>> >
>> > --
>> > John Mertic
>> > jmertic@gmail.com
>> > http://jmertic.wordpress.com
>> >
>> > "Explaining a joke is like dissecting a frog: you understand it
>> > better, but the frog dies
>> > in the process." --Mark Twain
>> >
>> > --
>> > PHP Windows Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>>
>>
>
>
> --
> John Mertic
> jmertic@gmail.com
> http://jmertic.wordpress.com
>
> "Explaining a joke is like dissecting a frog: you understand it
> better, but the frog dies
> in the process." --Mark Twain
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-memory leak with COM-objects?

am 10.10.2007 22:07:11 von John Mertic

Using PHP ( whether via COM or not ) in a web application to interact
with a file on the local user's machine isn't possible. PHP is a
server-side language in this context, and it interacts with the COM
object on the server which has no access to the user's local machine.

If the file is on the server, you can't push changes to it from the
Word editing control in IE, it will only allow saving changes to the
local computer.

If you are looking at doing the first option, then a PHP web app is
out of the question; perhaps a short VBScript to do any preprocessing
of the document would be in order. If you are looking at the second,
you may want to consider one of the Rich Text Editing tools that you
can drop in a webpage, such as FCKEditor or TinyMCE; these typically
will want input and output in XHTML however.

John

On 10/10/07, Gustav Wiberg wrote:
> Hi!
>
> It was just an example, but say Yes. Does it make a difference?
>
> Best regards
> /Gustav Wiberg
>
> ----- Original Message -----
> From: "John Mertic"
> To: "Gustav Wiberg"
> Cc: "PHP-Windows Group"
> Sent: Wednesday, October 10, 2007 7:55 PM
> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
>
>
> > Is c:\test.doc a file on the local user's machine or the server?
> >
> > On 10/10/07, Gustav Wiberg wrote:
> >> Hi again!
> >>
> >> I want the logged-in user to able to open a word-file (or an Excel-file
> >> or
> >> whatever) and then Push Save-Icon and make sure that changes are actually
> >> made.
> >> Example:
> >>
> >> John opens up file c:\test.doc. He writes "Ugly cow" in it and pushes the
> >> save-icon. Ugly Cow is now stored in file c:\test.doc. Working with
> >> COM-objects is the only solution I have found!?
> >>
> >> Normally If John opens up c:\test.doc Internet Explorer (or whatever
> >> browser) saves the file temporarily in some temp-folder (don't know exact
> >> location), lets say c:\temp\sdifiuweoriu2734872.tmp. When John pushes
> >> Save-icon he saves the new information TO the temporarily stored file IF
> >> he
> >> doesn't use Save AS...
> >>
> >> Please come with suggestions :-)
> >>
> >> Best regards
> >> /Gustav Wiberg
> >>
> >> ----- Original Message -----
> >> From: "John Mertic"
> >> To: "Gustav Wiberg"
> >> Cc: "PHP-Windows Group"
> >> Sent: Wednesday, October 10, 2007 1:30 PM
> >> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
> >>
> >>
> >> > I've worked a lot with the Word COM and while it works well on a
> >> > single desktop, I wouldn't recommend it for a server process. It's
> >> > rather slow and while the memory eventually gets cleaned up, it still
> >> > takes up a lot of memory for as little as it does. I'm not so sure
> >> > OpenOffice is much better in this regard.
> >> >
> >> > You could push these tasks to another server, but I'd also look at
> >> > what you are doing and see if you can do it another way. We currently
> >> > use Word documents as template for a mail merge type operation and are
> >> > looking to move these to RTF since that enables us to take Word out of
> >> > the loop when doing the mail merge ( we actually just do a global find
> >> > and replace in the document since we've found more consistent results
> >> > with that ). But again, this all depends upon the application.
> >> >
> >> > John
> >> >
> >> > On 10/10/07, Gustav Wiberg wrote:
> >> >> Hi!
> >> >>
> >> >> I want to use COM+ objects (especially with Word). I have understood
> >> >> (a
> >> >> lot of reading on the Internet) that when initiating COM-objects with
> >> >> Word (even if the object is released in variable in the code). Word
> >> >> leaks
> >> >> a lot of memory. I have also read that if I want to use Word-COM+
> >> >> object
> >> >> I should have a dedicated server because it takes so much memory.
> >> >>
> >> >> I have tested some and I easily get out of memory even if there is 4GB
> >> >> on
> >> >> the server I tested against.
> >> >>
> >> >> Then I run PHP as ISAPI, and the suggestion on the php.net site was to
> >> >> run PHP as CGI because COM-objects are run in the same memory-space as
> >> >> ISAPI when running as ISAPI-module.
> >> >> http://php.oregonstate.edu/manual/en/class.com.php
> >> >>
> >> >>
> >> >>
> >> >> What do you guys thinks about above? Give me some feedback, please :-)
> >> >>
> >> >> Best regards
> >> >> /Gustav Wiberg
> >> >>
> >> >>
> >> >> No virus found in this outgoing message.
> >> >> Checked by AVG Free Edition.
> >> >> Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date:
> >> >> 2007-10-09 16:43
> >> >>
> >> >>
> >> >> --
> >> >> PHP Windows Mailing List (http://www.php.net/)
> >> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > John Mertic
> >> > jmertic@gmail.com
> >> > http://jmertic.wordpress.com
> >> >
> >> > "Explaining a joke is like dissecting a frog: you understand it
> >> > better, but the frog dies
> >> > in the process." --Mark Twain
> >> >
> >> > --
> >> > PHP Windows Mailing List (http://www.php.net/)
> >> > To unsubscribe, visit: http://www.php.net/unsub.php
> >> >
> >> >
> >>
> >>
> >>
> >
> >
> > --
> > John Mertic
> > jmertic@gmail.com
> > http://jmertic.wordpress.com
> >
> > "Explaining a joke is like dissecting a frog: you understand it
> > better, but the frog dies
> > in the process." --Mark Twain
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
>


--
John Mertic
jmertic@gmail.com
http://jmertic.wordpress.com

"Explaining a joke is like dissecting a frog: you understand it
better, but the frog dies
in the process." --Mark Twain

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-memory leak with COM-objects?

am 10.10.2007 22:25:44 von Gustav Wiberg

Hi again!

I noticed I didn't pay enough attention to your question... Sorry for that.

The file is stored on the server!

And with COM-objects I managed to do a PHP-script - create a
(Word)-COM-object to open a certain file (say c:\test.doc on the server). I
changed te c:\test.doc from within the php-application and pushed Saved (in
the Word-object that open up). And Yes, the content changed in the file
c:\test.doc which is on the server.

TinyMCE or whatsoever is out of question. It must be word. I don't want to
change a whole organisations policy about using word... :-)

Best regards
/Gustav Wiberg




----- Original Message -----
From: "John Mertic"
To: "Gustav Wiberg"
Cc: "PHP-Windows Group"
Sent: Wednesday, October 10, 2007 10:07 PM
Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?


> Using PHP ( whether via COM or not ) in a web application to interact
> with a file on the local user's machine isn't possible. PHP is a
> server-side language in this context, and it interacts with the COM
> object on the server which has no access to the user's local machine.
>
> If the file is on the server, you can't push changes to it from the
> Word editing control in IE, it will only allow saving changes to the
> local computer.
>
> If you are looking at doing the first option, then a PHP web app is
> out of the question; perhaps a short VBScript to do any preprocessing
> of the document would be in order. If you are looking at the second,
> you may want to consider one of the Rich Text Editing tools that you
> can drop in a webpage, such as FCKEditor or TinyMCE; these typically
> will want input and output in XHTML however.
>
> John
>
> On 10/10/07, Gustav Wiberg wrote:
>> Hi!
>>
>> It was just an example, but say Yes. Does it make a difference?
>>
>> Best regards
>> /Gustav Wiberg
>>
>> ----- Original Message -----
>> From: "John Mertic"
>> To: "Gustav Wiberg"
>> Cc: "PHP-Windows Group"
>> Sent: Wednesday, October 10, 2007 7:55 PM
>> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
>>
>>
>> > Is c:\test.doc a file on the local user's machine or the server?
>> >
>> > On 10/10/07, Gustav Wiberg wrote:
>> >> Hi again!
>> >>
>> >> I want the logged-in user to able to open a word-file (or an
>> >> Excel-file
>> >> or
>> >> whatever) and then Push Save-Icon and make sure that changes are
>> >> actually
>> >> made.
>> >> Example:
>> >>
>> >> John opens up file c:\test.doc. He writes "Ugly cow" in it and pushes
>> >> the
>> >> save-icon. Ugly Cow is now stored in file c:\test.doc. Working with
>> >> COM-objects is the only solution I have found!?
>> >>
>> >> Normally If John opens up c:\test.doc Internet Explorer (or whatever
>> >> browser) saves the file temporarily in some temp-folder (don't know
>> >> exact
>> >> location), lets say c:\temp\sdifiuweoriu2734872.tmp. When John pushes
>> >> Save-icon he saves the new information TO the temporarily stored file
>> >> IF
>> >> he
>> >> doesn't use Save AS...
>> >>
>> >> Please come with suggestions :-)
>> >>
>> >> Best regards
>> >> /Gustav Wiberg
>> >>
>> >> ----- Original Message -----
>> >> From: "John Mertic"
>> >> To: "Gustav Wiberg"
>> >> Cc: "PHP-Windows Group"
>> >> Sent: Wednesday, October 10, 2007 1:30 PM
>> >> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
>> >>
>> >>
>> >> > I've worked a lot with the Word COM and while it works well on a
>> >> > single desktop, I wouldn't recommend it for a server process. It's
>> >> > rather slow and while the memory eventually gets cleaned up, it
>> >> > still
>> >> > takes up a lot of memory for as little as it does. I'm not so sure
>> >> > OpenOffice is much better in this regard.
>> >> >
>> >> > You could push these tasks to another server, but I'd also look at
>> >> > what you are doing and see if you can do it another way. We
>> >> > currently
>> >> > use Word documents as template for a mail merge type operation and
>> >> > are
>> >> > looking to move these to RTF since that enables us to take Word out
>> >> > of
>> >> > the loop when doing the mail merge ( we actually just do a global
>> >> > find
>> >> > and replace in the document since we've found more consistent
>> >> > results
>> >> > with that ). But again, this all depends upon the application.
>> >> >
>> >> > John
>> >> >
>> >> > On 10/10/07, Gustav Wiberg wrote:
>> >> >> Hi!
>> >> >>
>> >> >> I want to use COM+ objects (especially with Word). I have
>> >> >> understood
>> >> >> (a
>> >> >> lot of reading on the Internet) that when initiating COM-objects
>> >> >> with
>> >> >> Word (even if the object is released in variable in the code). Word
>> >> >> leaks
>> >> >> a lot of memory. I have also read that if I want to use Word-COM+
>> >> >> object
>> >> >> I should have a dedicated server because it takes so much memory.
>> >> >>
>> >> >> I have tested some and I easily get out of memory even if there is
>> >> >> 4GB
>> >> >> on
>> >> >> the server I tested against.
>> >> >>
>> >> >> Then I run PHP as ISAPI, and the suggestion on the php.net site was
>> >> >> to
>> >> >> run PHP as CGI because COM-objects are run in the same memory-space
>> >> >> as
>> >> >> ISAPI when running as ISAPI-module.
>> >> >> http://php.oregonstate.edu/manual/en/class.com.php
>> >> >>
>> >> >>
>> >> >>
>> >> >> What do you guys thinks about above? Give me some feedback, please
>> >> >> :-)
>> >> >>
>> >> >> Best regards
>> >> >> /Gustav Wiberg
>> >> >>
>> >> >>
>> >> >> No virus found in this outgoing message.
>> >> >> Checked by AVG Free Edition.
>> >> >> Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date:
>> >> >> 2007-10-09 16:43
>> >> >>
>> >> >>
>> >> >> --
>> >> >> PHP Windows Mailing List (http://www.php.net/)
>> >> >> To unsubscribe, visit: http://www.php.net/unsub.php
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > --
>> >> > John Mertic
>> >> > jmertic@gmail.com
>> >> > http://jmertic.wordpress.com
>> >> >
>> >> > "Explaining a joke is like dissecting a frog: you understand it
>> >> > better, but the frog dies
>> >> > in the process." --Mark Twain
>> >> >
>> >> > --
>> >> > PHP Windows Mailing List (http://www.php.net/)
>> >> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >
>> >
>> > --
>> > John Mertic
>> > jmertic@gmail.com
>> > http://jmertic.wordpress.com
>> >
>> > "Explaining a joke is like dissecting a frog: you understand it
>> > better, but the frog dies
>> > in the process." --Mark Twain
>> >
>> > --
>> > PHP Windows Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>>
>>
>
>
> --
> John Mertic
> jmertic@gmail.com
> http://jmertic.wordpress.com
>
> "Explaining a joke is like dissecting a frog: you understand it
> better, but the frog dies
> in the process." --Mark Twain
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-memory leak with COM-objects?

am 11.10.2007 13:23:41 von John Mertic

Do you have a working demo of what you are doing with Word COM and
PHP? I'm kinda curious since I've never seen anyone be able to save a
document back to the webserver like that. Are you setting some special
permissions on the webserver?

John

On 10/10/07, Gustav Wiberg wrote:
> Hi again!
>
> I noticed I didn't pay enough attention to your question... Sorry for that.
>
> The file is stored on the server!
>
> And with COM-objects I managed to do a PHP-script - create a
> (Word)-COM-object to open a certain file (say c:\test.doc on the server). I
> changed te c:\test.doc from within the php-application and pushed Saved (in
> the Word-object that open up). And Yes, the content changed in the file
> c:\test.doc which is on the server.
>
> TinyMCE or whatsoever is out of question. It must be word. I don't want to
> change a whole organisations policy about using word... :-)
>
> Best regards
> /Gustav Wiberg
>
>
>
>
> ----- Original Message -----
> From: "John Mertic"
> To: "Gustav Wiberg"
> Cc: "PHP-Windows Group"
> Sent: Wednesday, October 10, 2007 10:07 PM
> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
>
>
> > Using PHP ( whether via COM or not ) in a web application to interact
> > with a file on the local user's machine isn't possible. PHP is a
> > server-side language in this context, and it interacts with the COM
> > object on the server which has no access to the user's local machine.
> >
> > If the file is on the server, you can't push changes to it from the
> > Word editing control in IE, it will only allow saving changes to the
> > local computer.
> >
> > If you are looking at doing the first option, then a PHP web app is
> > out of the question; perhaps a short VBScript to do any preprocessing
> > of the document would be in order. If you are looking at the second,
> > you may want to consider one of the Rich Text Editing tools that you
> > can drop in a webpage, such as FCKEditor or TinyMCE; these typically
> > will want input and output in XHTML however.
> >
> > John
> >
> > On 10/10/07, Gustav Wiberg wrote:
> >> Hi!
> >>
> >> It was just an example, but say Yes. Does it make a difference?
> >>
> >> Best regards
> >> /Gustav Wiberg
> >>
> >> ----- Original Message -----
> >> From: "John Mertic"
> >> To: "Gustav Wiberg"
> >> Cc: "PHP-Windows Group"
> >> Sent: Wednesday, October 10, 2007 7:55 PM
> >> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
> >>
> >>
> >> > Is c:\test.doc a file on the local user's machine or the server?
> >> >
> >> > On 10/10/07, Gustav Wiberg wrote:
> >> >> Hi again!
> >> >>
> >> >> I want the logged-in user to able to open a word-file (or an
> >> >> Excel-file
> >> >> or
> >> >> whatever) and then Push Save-Icon and make sure that changes are
> >> >> actually
> >> >> made.
> >> >> Example:
> >> >>
> >> >> John opens up file c:\test.doc. He writes "Ugly cow" in it and pushes
> >> >> the
> >> >> save-icon. Ugly Cow is now stored in file c:\test.doc. Working with
> >> >> COM-objects is the only solution I have found!?
> >> >>
> >> >> Normally If John opens up c:\test.doc Internet Explorer (or whatever
> >> >> browser) saves the file temporarily in some temp-folder (don't know
> >> >> exact
> >> >> location), lets say c:\temp\sdifiuweoriu2734872.tmp. When John pushes
> >> >> Save-icon he saves the new information TO the temporarily stored file
> >> >> IF
> >> >> he
> >> >> doesn't use Save AS...
> >> >>
> >> >> Please come with suggestions :-)
> >> >>
> >> >> Best regards
> >> >> /Gustav Wiberg
> >> >>
> >> >> ----- Original Message -----
> >> >> From: "John Mertic"
> >> >> To: "Gustav Wiberg"
> >> >> Cc: "PHP-Windows Group"
> >> >> Sent: Wednesday, October 10, 2007 1:30 PM
> >> >> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
> >> >>
> >> >>
> >> >> > I've worked a lot with the Word COM and while it works well on a
> >> >> > single desktop, I wouldn't recommend it for a server process. It's
> >> >> > rather slow and while the memory eventually gets cleaned up, it
> >> >> > still
> >> >> > takes up a lot of memory for as little as it does. I'm not so sure
> >> >> > OpenOffice is much better in this regard.
> >> >> >
> >> >> > You could push these tasks to another server, but I'd also look at
> >> >> > what you are doing and see if you can do it another way. We
> >> >> > currently
> >> >> > use Word documents as template for a mail merge type operation and
> >> >> > are
> >> >> > looking to move these to RTF since that enables us to take Word out
> >> >> > of
> >> >> > the loop when doing the mail merge ( we actually just do a global
> >> >> > find
> >> >> > and replace in the document since we've found more consistent
> >> >> > results
> >> >> > with that ). But again, this all depends upon the application.
> >> >> >
> >> >> > John
> >> >> >
> >> >> > On 10/10/07, Gustav Wiberg wrote:
> >> >> >> Hi!
> >> >> >>
> >> >> >> I want to use COM+ objects (especially with Word). I have
> >> >> >> understood
> >> >> >> (a
> >> >> >> lot of reading on the Internet) that when initiating COM-objects
> >> >> >> with
> >> >> >> Word (even if the object is released in variable in the code). Word
> >> >> >> leaks
> >> >> >> a lot of memory. I have also read that if I want to use Word-COM+
> >> >> >> object
> >> >> >> I should have a dedicated server because it takes so much memory.
> >> >> >>
> >> >> >> I have tested some and I easily get out of memory even if there is
> >> >> >> 4GB
> >> >> >> on
> >> >> >> the server I tested against.
> >> >> >>
> >> >> >> Then I run PHP as ISAPI, and the suggestion on the php.net site was
> >> >> >> to
> >> >> >> run PHP as CGI because COM-objects are run in the same memory-space
> >> >> >> as
> >> >> >> ISAPI when running as ISAPI-module.
> >> >> >> http://php.oregonstate.edu/manual/en/class.com.php
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> What do you guys thinks about above? Give me some feedback, please
> >> >> >> :-)
> >> >> >>
> >> >> >> Best regards
> >> >> >> /Gustav Wiberg
> >> >> >>
> >> >> >>
> >> >> >> No virus found in this outgoing message.
> >> >> >> Checked by AVG Free Edition.
> >> >> >> Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date:
> >> >> >> 2007-10-09 16:43
> >> >> >>
> >> >> >>
> >> >> >> --
> >> >> >> PHP Windows Mailing List (http://www.php.net/)
> >> >> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >> > --
> >> >> > John Mertic
> >> >> > jmertic@gmail.com
> >> >> > http://jmertic.wordpress.com
> >> >> >
> >> >> > "Explaining a joke is like dissecting a frog: you understand it
> >> >> > better, but the frog dies
> >> >> > in the process." --Mark Twain
> >> >> >
> >> >> > --
> >> >> > PHP Windows Mailing List (http://www.php.net/)
> >> >> > To unsubscribe, visit: http://www.php.net/unsub.php
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > John Mertic
> >> > jmertic@gmail.com
> >> > http://jmertic.wordpress.com
> >> >
> >> > "Explaining a joke is like dissecting a frog: you understand it
> >> > better, but the frog dies
> >> > in the process." --Mark Twain
> >> >
> >> > --
> >> > PHP Windows Mailing List (http://www.php.net/)
> >> > To unsubscribe, visit: http://www.php.net/unsub.php
> >> >
> >> >
> >>
> >>
> >>
> >
> >
> > --
> > John Mertic
> > jmertic@gmail.com
> > http://jmertic.wordpress.com
> >
> > "Explaining a joke is like dissecting a frog: you understand it
> > better, but the frog dies
> > in the process." --Mark Twain
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
>


--
John Mertic
jmertic@gmail.com
http://jmertic.wordpress.com

"Explaining a joke is like dissecting a frog: you understand it
better, but the frog dies
in the process." --Mark Twain

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: PHP-memory leak with COM-objects?

am 12.10.2007 08:45:00 von Gustav Wiberg

Hi!

No, I'm not doing anything specific though:
(PHP 5.2, IIS 6.0, Win2003 Server, Word 2003)


$word =3D new COM("Word.Application");
//It's better to keep Word invisible
$word->Visible =3D 1;
$word->Documents->Open("c:\\test.doc");

$word =3D null;
?>

No, not special permissions. It might be that IIS Out of process is running=
.. On some systems this don't seem to run and some system it does. I don't k=
now why, but when IIS Out Of process-component service is active then the w=
ord-object-com-"application" work.

I can't give you any working application though, because the server I'm tes=
ting on is at a customer.

Best regards
/Gustav Wiberg

=20

-----Original Message-----
From: John Mertic [mailto:jmertic@gmail.com]=20
Sent: Thursday, October 11, 2007 1:24 PM
To: Gustav Wiberg
Cc: PHP-Windows Group
Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?

Do you have a working demo of what you are doing with Word COM and
PHP? I'm kinda curious since I've never seen anyone be able to save a
document back to the webserver like that. Are you setting some special
permissions on the webserver?

John

On 10/10/07, Gustav Wiberg wrote:
> Hi again!
>
> I noticed I didn't pay enough attention to your question... Sorry for tha=
t.
>
> The file is stored on the server!
>
> And with COM-objects I managed to do a PHP-script - create a
> (Word)-COM-object to open a certain file (say c:\test.doc on the server).=
I
> changed te c:\test.doc from within the php-application and pushed Saved (=
in
> the Word-object that open up). And Yes, the content changed in the file
> c:\test.doc which is on the server.
>
> TinyMCE or whatsoever is out of question. It must be word. I don't want t=
o
> change a whole organisations policy about using word... :-)
>
> Best regards
> /Gustav Wiberg
>
>
>
>
> ----- Original Message -----
> From: "John Mertic"
> To: "Gustav Wiberg"
> Cc: "PHP-Windows Group"
> Sent: Wednesday, October 10, 2007 10:07 PM
> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
>
>
> > Using PHP ( whether via COM or not ) in a web application to interact
> > with a file on the local user's machine isn't possible. PHP is a
> > server-side language in this context, and it interacts with the COM
> > object on the server which has no access to the user's local machine.
> >
> > If the file is on the server, you can't push changes to it from the
> > Word editing control in IE, it will only allow saving changes to the
> > local computer.
> >
> > If you are looking at doing the first option, then a PHP web app is
> > out of the question; perhaps a short VBScript to do any preprocessing
> > of the document would be in order. If you are looking at the second,
> > you may want to consider one of the Rich Text Editing tools that you
> > can drop in a webpage, such as FCKEditor or TinyMCE; these typically
> > will want input and output in XHTML however.
> >
> > John
> >
> > On 10/10/07, Gustav Wiberg wrote:
> >> Hi!
> >>
> >> It was just an example, but say Yes. Does it make a difference?
> >>
> >> Best regards
> >> /Gustav Wiberg
> >>
> >> ----- Original Message -----
> >> From: "John Mertic"
> >> To: "Gustav Wiberg"
> >> Cc: "PHP-Windows Group"
> >> Sent: Wednesday, October 10, 2007 7:55 PM
> >> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
> >>
> >>
> >> > Is c:\test.doc a file on the local user's machine or the server?
> >> >
> >> > On 10/10/07, Gustav Wiberg wrote:
> >> >> Hi again!
> >> >>
> >> >> I want the logged-in user to able to open a word-file (or an
> >> >> Excel-file
> >> >> or
> >> >> whatever) and then Push Save-Icon and make sure that changes are
> >> >> actually
> >> >> made.
> >> >> Example:
> >> >>
> >> >> John opens up file c:\test.doc. He writes "Ugly cow" in it and push=
es
> >> >> the
> >> >> save-icon. Ugly Cow is now stored in file c:\test.doc. Working with
> >> >> COM-objects is the only solution I have found!?
> >> >>
> >> >> Normally If John opens up c:\test.doc Internet Explorer (or whateve=
r
> >> >> browser) saves the file temporarily in some temp-folder (don't know
> >> >> exact
> >> >> location), lets say c:\temp\sdifiuweoriu2734872.tmp. When John push=
es
> >> >> Save-icon he saves the new information TO the temporarily stored fi=
le
> >> >> IF
> >> >> he
> >> >> doesn't use Save AS...
> >> >>
> >> >> Please come with suggestions :-)
> >> >>
> >> >> Best regards
> >> >> /Gustav Wiberg
> >> >>
> >> >> ----- Original Message -----
> >> >> From: "John Mertic"
> >> >> To: "Gustav Wiberg"
> >> >> Cc: "PHP-Windows Group"
> >> >> Sent: Wednesday, October 10, 2007 1:30 PM
> >> >> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
> >> >>
> >> >>
> >> >> > I've worked a lot with the Word COM and while it works well on a
> >> >> > single desktop, I wouldn't recommend it for a server process. It'=
s
> >> >> > rather slow and while the memory eventually gets cleaned up, it
> >> >> > still
> >> >> > takes up a lot of memory for as little as it does. I'm not so sur=
e
> >> >> > OpenOffice is much better in this regard.
> >> >> >
> >> >> > You could push these tasks to another server, but I'd also look a=
t
> >> >> > what you are doing and see if you can do it another way. We
> >> >> > currently
> >> >> > use Word documents as template for a mail merge type operation an=
d
> >> >> > are
> >> >> > looking to move these to RTF since that enables us to take Word o=
ut
> >> >> > of
> >> >> > the loop when doing the mail merge ( we actually just do a global
> >> >> > find
> >> >> > and replace in the document since we've found more consistent
> >> >> > results
> >> >> > with that ). But again, this all depends upon the application.
> >> >> >
> >> >> > John
> >> >> >
> >> >> > On 10/10/07, Gustav Wiberg wrote:
> >> >> >> Hi!
> >> >> >>
> >> >> >> I want to use COM+ objects (especially with Word). I have
> >> >> >> understood
> >> >> >> (a
> >> >> >> lot of reading on the Internet) that when initiating COM-objects
> >> >> >> with
> >> >> >> Word (even if the object is released in variable in the code). W=
ord
> >> >> >> leaks
> >> >> >> a lot of memory. I have also read that if I want to use Word-COM=
+
> >> >> >> object
> >> >> >> I should have a dedicated server because it takes so much memory=
..
> >> >> >>
> >> >> >> I have tested some and I easily get out of memory even if there =
is
> >> >> >> 4GB
> >> >> >> on
> >> >> >> the server I tested against.
> >> >> >>
> >> >> >> Then I run PHP as ISAPI, and the suggestion on the php.net site =
was
> >> >> >> to
> >> >> >> run PHP as CGI because COM-objects are run in the same memory-sp=
ace
> >> >> >> as
> >> >> >> ISAPI when running as ISAPI-module.
> >> >> >> http://php.oregonstate.edu/manual/en/class.com.php
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> What do you guys thinks about above? Give me some feedback, plea=
se
> >> >> >> :-)
> >> >> >>
> >> >> >> Best regards
> >> >> >> /Gustav Wiberg
> >> >> >>
> >> >> >>
> >> >> >> No virus found in this outgoing message.
> >> >> >> Checked by AVG Free Edition.
> >> >> >> Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date:
> >> >> >> 2007-10-09 16:43
> >> >> >>
> >> >> >>
> >> >> >> --
> >> >> >> PHP Windows Mailing List (http://www.php.net/)
> >> >> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >> >> >>
> >> >> >>
> >> >> >
> >> >> >
> >> >> > --
> >> >> > John Mertic
> >> >> > jmertic@gmail.com
> >> >> > http://jmertic.wordpress.com
> >> >> >
> >> >> > "Explaining a joke is like dissecting a frog: you understand it
> >> >> > better, but the frog dies
> >> >> > in the process." --Mark Twain
> >> >> >
> >> >> > --
> >> >> > PHP Windows Mailing List (http://www.php.net/)
> >> >> > To unsubscribe, visit: http://www.php.net/unsub.php
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> > --
> >> > John Mertic
> >> > jmertic@gmail.com
> >> > http://jmertic.wordpress.com
> >> >
> >> > "Explaining a joke is like dissecting a frog: you understand it
> >> > better, but the frog dies
> >> > in the process." --Mark Twain
> >> >
> >> > --
> >> > PHP Windows Mailing List (http://www.php.net/)
> >> > To unsubscribe, visit: http://www.php.net/unsub.php
> >> >
> >> >
> >>
> >>
> >>
> >
> >
> > --
> > John Mertic
> > jmertic@gmail.com
> > http://jmertic.wordpress.com
> >
> > "Explaining a joke is like dissecting a frog: you understand it
> > better, but the frog dies
> > in the process." --Mark Twain
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
>


--=20
John Mertic
jmertic@gmail.com
http://jmertic.wordpress.com

"Explaining a joke is like dissecting a frog: you understand it
better, but the frog dies
in the process." --Mark Twain

--=20
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


No virus found in this outgoing message.
Checked by AVG Free Edition.=20
Version: 7.5.488 / Virus Database: 269.14.8/1064 - Release Date: 2007-10-11=
15:09
=20

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: PHP-memory leak with COM-objects?

am 17.10.2007 02:30:52 von Rafael

I'm a little late on the thread, so I apologize in advance if I say
something out of context / already mentioned.

Thank's God, I haven't had the need to use PHP + COM + MS Office, but I
did use C# + MS Office, and I found that for desktop applications
Application.Quit() was enough, whereas in ASP (.Net) I had to kill the
process --and yes, I did made all the dance about calling the GC,
ReleaseComObject and such. So, if possible, don't use COM.

Now, as for what seem to be want, is it like...
a) open "x.doc" with PHP+COM+Word
b) the user makes changes
c) "x.doc" gets saved with the changes
Is it like this?

If it is, then you are trying to do something I don't think is
possible, because the user will be working on the Client machine, not on
the Server, hence, PHP will have no access to it unless the client sends
you his "x.doc" version and you replace the existent one with it.

So why don't you simple take it as a file server? Something like I send
you the current version, you make the changes (on your PC) and them you
deliver it to me once again --yes, there will be "synchronization"
issues with this approach, and you can only _help_ the user check it
with a time-stamp or something similar.

Hope this helps.

Gustav Wiberg wrote:
> Hi again!
>
> I noticed I didn't pay enough attention to your question... Sorry for that.
>
> The file is stored on the server!
>
> And with COM-objects I managed to do a PHP-script - create a
> (Word)-COM-object to open a certain file (say c:\test.doc on the
> server). I changed te c:\test.doc from within the php-application and
> pushed Saved (in the Word-object that open up). And Yes, the content
> changed in the file c:\test.doc which is on the server.
>
> TinyMCE or whatsoever is out of question. It must be word. I don't want
> to change a whole organisations policy about using word... :-)
>
> Best regards
> /Gustav Wiberg
>
>
>
>
> ----- Original Message ----- From: "John Mertic"
> To: "Gustav Wiberg"
> Cc: "PHP-Windows Group"
> Sent: Wednesday, October 10, 2007 10:07 PM
> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
>
>
>> Using PHP ( whether via COM or not ) in a web application to interact
>> with a file on the local user's machine isn't possible. PHP is a
>> server-side language in this context, and it interacts with the COM
>> object on the server which has no access to the user's local machine.
>>
>> If the file is on the server, you can't push changes to it from the
>> Word editing control in IE, it will only allow saving changes to the
>> local computer.
>>
>> If you are looking at doing the first option, then a PHP web app is
>> out of the question; perhaps a short VBScript to do any preprocessing
>> of the document would be in order. If you are looking at the second,
>> you may want to consider one of the Rich Text Editing tools that you
>> can drop in a webpage, such as FCKEditor or TinyMCE; these typically
>> will want input and output in XHTML however.
>>
>> John
>>
>> On 10/10/07, Gustav Wiberg wrote:
>>> Hi!
>>>
>>> It was just an example, but say Yes. Does it make a difference?
>>>
>>> Best regards
>>> /Gustav Wiberg
>>>
>>> ----- Original Message -----
>>> From: "John Mertic"
>>> To: "Gustav Wiberg"
>>> Cc: "PHP-Windows Group"
>>> Sent: Wednesday, October 10, 2007 7:55 PM
>>> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
>>>
>>>
>>> > Is c:\test.doc a file on the local user's machine or the server?
>>> >
>>> > On 10/10/07, Gustav Wiberg wrote:
>>> >> Hi again!
>>> >>
>>> >> I want the logged-in user to able to open a word-file (or an >>
>>> Excel-file
>>> >> or
>>> >> whatever) and then Push Save-Icon and make sure that changes are
>>> >> actually
>>> >> made.
>>> >> Example:
>>> >>
>>> >> John opens up file c:\test.doc. He writes "Ugly cow" in it and
>>> pushes >> the
>>> >> save-icon. Ugly Cow is now stored in file c:\test.doc. Working with
>>> >> COM-objects is the only solution I have found!?
>>> >>
>>> >> Normally If John opens up c:\test.doc Internet Explorer (or whatever
>>> >> browser) saves the file temporarily in some temp-folder (don't
>>> know >> exact
>>> >> location), lets say c:\temp\sdifiuweoriu2734872.tmp. When John pushes
>>> >> Save-icon he saves the new information TO the temporarily stored
>>> file >> IF
>>> >> he
>>> >> doesn't use Save AS...
>>> >>
>>> >> Please come with suggestions :-)
>>> >>
>>> >> Best regards
>>> >> /Gustav Wiberg
>>> >>
>>> >> ----- Original Message -----
>>> >> From: "John Mertic"
>>> >> To: "Gustav Wiberg"
>>> >> Cc: "PHP-Windows Group"
>>> >> Sent: Wednesday, October 10, 2007 1:30 PM
>>> >> Subject: Re: [PHP-WIN] PHP-memory leak with COM-objects?
>>> >>
>>> >>
>>> >> > I've worked a lot with the Word COM and while it works well on a
>>> >> > single desktop, I wouldn't recommend it for a server process. It's
>>> >> > rather slow and while the memory eventually gets cleaned up, it
>>> >> > still
>>> >> > takes up a lot of memory for as little as it does. I'm not so sure
>>> >> > OpenOffice is much better in this regard.
>>> >> >
>>> >> > You could push these tasks to another server, but I'd also look at
>>> >> > what you are doing and see if you can do it another way. We >> >
>>> currently
>>> >> > use Word documents as template for a mail merge type operation
>>> and >> > are
>>> >> > looking to move these to RTF since that enables us to take Word
>>> out >> > of
>>> >> > the loop when doing the mail merge ( we actually just do a
>>> global >> > find
>>> >> > and replace in the document since we've found more consistent >>
>>> > results
>>> >> > with that ). But again, this all depends upon the application.
>>> >> >
>>> >> > John
>>> >> >
>>> >> > On 10/10/07, Gustav Wiberg wrote:
>>> >> >> Hi!
>>> >> >>
>>> >> >> I want to use COM+ objects (especially with Word). I have >> >>
>>> understood
>>> >> >> (a
>>> >> >> lot of reading on the Internet) that when initiating
>>> COM-objects >> >> with
>>> >> >> Word (even if the object is released in variable in the code).
>>> Word
>>> >> >> leaks
>>> >> >> a lot of memory. I have also read that if I want to use Word-COM+
>>> >> >> object
>>> >> >> I should have a dedicated server because it takes so much memory.
>>> >> >>
>>> >> >> I have tested some and I easily get out of memory even if there
>>> is >> >> 4GB
>>> >> >> on
>>> >> >> the server I tested against.
>>> >> >>
>>> >> >> Then I run PHP as ISAPI, and the suggestion on the php.net site
>>> was >> >> to
>>> >> >> run PHP as CGI because COM-objects are run in the same
>>> memory-space >> >> as
>>> >> >> ISAPI when running as ISAPI-module.
>>> >> >> http://php.oregonstate.edu/manual/en/class.com.php
>>> >> >>
>>> >> >>
>>> >> >>
>>> >> >> What do you guys thinks about above? Give me some feedback,
>>> please >> >> :-)
>>> >> >>
>>> >> >> Best regards
>>> >> >> /Gustav Wiberg
>>> >> >>
>>> >> >>
>>> >> >> No virus found in this outgoing message.
>>> >> >> Checked by AVG Free Edition.
>>> >> >> Version: 7.5.488 / Virus Database: 269.14.6/1060 - Release Date:
>>> >> >> 2007-10-09 16:43
>>> >> >>
>>> >> >>
>>> >> >> --
>>> >> >> PHP Windows Mailing List (http://www.php.net/)
>>> >> >> To unsubscribe, visit: http://www.php.net/unsub.php
>>> >> >>
>>> >> >>
>>> >> >
>>> >> >
>>> >> > --
>>> >> > John Mertic
>>> >> > jmertic@gmail.com
>>> >> > http://jmertic.wordpress.com
>>> >> >
>>> >> > "Explaining a joke is like dissecting a frog: you understand it
>>> >> > better, but the frog dies
>>> >> > in the process." --Mark Twain
>>> >> >
>>> >> > --
>>> >> > PHP Windows Mailing List (http://www.php.net/)
>>> >> > To unsubscribe, visit: http://www.php.net/unsub.php
>>> >> >
>>> >> >
>>> >>
>>> >>
>>> >>
>>> >
>>> >
>>> > --
>>> > John Mertic
>>> > jmertic@gmail.com
>>> > http://jmertic.wordpress.com
>>> >
>>> > "Explaining a joke is like dissecting a frog: you understand it
>>> > better, but the frog dies
>>> > in the process." --Mark Twain
>>> >
>>> > --
>>> > PHP Windows Mailing List (http://www.php.net/)
>>> > To unsubscribe, visit: http://www.php.net/unsub.php
>>> >
>>> >
>>>
>>>
>>>
>>
>>
>> --
>> John Mertic
>> jmertic@gmail.com
>> http://jmertic.wordpress.com
>>
>> "Explaining a joke is like dissecting a frog: you understand it
>> better, but the frog dies
>> in the process." --Mark Twain
>>
>> --
>> PHP Windows Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php