"There is insufficient memory. Save the document now".

G

Guest

Hi,

I am writing an external utility that would just open and close all the Word
documents in a particular directory tree, catching the exceptions thrown if
any and logging them, to identify documents that crash Word. More often than
not, the directory tree contains around 2000 - 3000 documents. Initially i
used a single Word process to open and close all these docs and i kept
getting memory problems and i could not avoid any dialogs (security) shown
by Word, so now i open one Word process for each document, and time out to
avoid the dialogs. All is fine as long i run this on a small document
repository of aroun few hundred documents, but when i run it on large
repositories, typically containing 2000 - 3000 documents, it runs for around
1000 docs without any problem and then for all the docs I try to open, i get
the exception "There is insufficient memory. Save the document now". Can
someone help me out here??

More specifically can Word process be created and killed around 2000 times
without any problems, programmatically? I am using C#.NET and Word 11.0
object library.


Thanks and Regards,
Laks
 
C

Cindy M -WordMVP-

1. The error message you quote is very "generalized", and often doesn't
reflect the true problem.

2. It's more than possible that you ARE running out of memory, if too many
instances of Word have been opened, and aren't having time to close and remove
themselves from memory.

3. Are you certain you're releasing all pointers to the Word instance?

4. You say you're using C#. Could you be running into Garbage Collection
problems in the COM interface, so that the instances aren't being fully
released, and therefore not clearing up resources?

5. Are you able to check how many instances are still active when this
messages appears?
I am writing an external utility that would just open and close all the Word
documents in a particular directory tree, catching the exceptions thrown if
any and logging them, to identify documents that crash Word. More often than
not, the directory tree contains around 2000 - 3000 documents. Initially i
used a single Word process to open and close all these docs and i kept
getting memory problems and i could not avoid any dialogs (security) shown
by Word, so now i open one Word process for each document, and time out to
avoid the dialogs. All is fine as long i run this on a small document
repository of aroun few hundred documents, but when i run it on large
repositories, typically containing 2000 - 3000 documents, it runs for around
1000 docs without any problem and then for all the docs I try to open, i get
the exception "There is insufficient memory. Save the document now". Can
someone help me out here??

More specifically can Word process be created and killed around 2000 times
without any problems, programmatically? I am using C#.NET and Word 11.0
object library.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
G

Guest

Hi,
1. The error message you quote is very "generalized", and often doesn't
reflect the true problem.

Too true. Thats why i am perplexed.
2. It's more than possible that you ARE running out of memory, if too many
instances of Word have been opened, and aren't having time to close and remove
themselves from memory.

This could be a reason. But i am having only one instance of Word in memory
at any point of time.
3. Are you certain you're releasing all pointers to the Word instance?

Yes i am releasing the references to Word object
4. You say you're using C#. Could you be running into Garbage Collection
problems in the COM interface, so that the instances aren't being fully
released, and therefore not clearing up resources?

Not only am i specifically calling the GC.Collect() [that forces garbage
collection], i am also calling Marsha.ReleaseCOMObject().
5. Are you able to check how many instances are still active when this
messages appears?

Yes i am able to check this and there is only one Word instance in memory
active, when i get this. I'll be more specific here. I am getting this
message as an exception, when i try to open a document programmatically. And
sometimes, it gets even worse and i explicitly get a error dialog "The is
not sufficient memory or disk space to run Word". I have searched this far
and low, to find that this is a problem (if not actually a memory problem)
associated with corrupt normal.dot etc etc.. but then i am not getting this
when manually opening a document or the very first doc i try and open
programmatically, but after actually processing hundreds of documents.

And i have one more question, is there anyway to create a Word instance
programmatically simulating a WINWORD /a... startup switch? I thought i ll
try this too, if it was possible.

Thanks and Regards,
Laks
 
C

Cindy M -WordMVP-

And i have one more question, is there anyway to create a Word instance
programmatically simulating a WINWORD /a... startup switch? I thought i ll
try this too, if it was possible.
Using the equivalent of the classicVB SHELL command you could start up Word
this way. I'm not sure there's a .NET equivalent of GetObject, though, to pick
it up once it's started? But that would at least let you test whether you can
start it up, directly.

I'm going to have to let my subconscious chew on this some more, since we've
eliminated the "obvious". The one thing that does occur to me, right now, is
that Word is writing to, opening and closing various temp and scratch files
for every document. Perhaps, at some point, it gets in a tangle if things are
moving too quickly. If you stuck something in the loop after, say, every 200
files, that would let the system Sleep for a minute to give Word a chance to
clean up, does that make any difference?

Note: this turned out to be why a dev was having a problem getting Shapes
placed correctly. Totally different situation, but since there are things in
Word that run asynchronously, perhaps...
Yes i am able to check this and there is only one Word instance in memory
active, when i get this. I'll be more specific here. I am getting this
message as an exception, when i try to open a document programmatically. And
sometimes, it gets even worse and i explicitly get a error dialog "The is
not sufficient memory or disk space to run Word". I have searched this far
and low, to find that this is a problem (if not actually a memory problem)
associated with corrupt normal.dot etc etc.. but then i am not getting this
when manually opening a document or the very first doc i try and open
programmatically, but after actually processing hundreds of documents.


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
G

Guest

YES Cindy... Thanks very much, YOU ARE ON THE DOT.... I pretty much found
that Word was creating a lot of temporary files and these weren't being
cleaned up and thats why the insufficient memory exception.... but really
crazy that these temp files weren't cleaned up by Word itself on doc close
as it created them.. so i do it myself... The exception problem is
solved....
but another has cropped up a different newer kind of problem that i have
been trying to solve for 8 hours now.... aaaah... What happens is that
everthing is running smoothly and nicely until suddenly without warning, the
MS Word Crash (Report, Dont Send) dialog crops up, and i am getting an
exception too (as things should normally work but in addition i get this
dialog too... what i am really trying do is make this process non -
interactive.... so this dialog spoils the party) and until i respond to the
dialog, the application simply waits in the exception block....

Sometimes this happens for the same document twice, and sometimes it just
happens for a different doc, different sequence!! I tried to run the same on
a directory containing only that doc and it works fine.. but when i run it
on an ancestor, then the crash dialog appears.... Any insights??
Using the equivalent of the classicVB SHELL command you could start up Word
this way. I'm not sure there's a .NET equivalent of GetObject, though, to pick
it up once it's started? But that would at least let you test whether you can
start it up, directly.
As far as i have used .NET, there's only an equivalent of CreateObject,
which uses the ProgId - "Word.Application".. Will research this though......

Thanks and Regards,
Laks
 
C

Cindy M -WordMVP-

What happens is that
everthing is running smoothly and nicely until suddenly without warning, the
MS Word Crash (Report, Dont Send) dialog crops up, and i am getting an
exception too (as things should normally work but in addition i get this
dialog too... what i am really trying do is make this process non -
interactive.... so this dialog spoils the party) and until i respond to the
dialog, the application simply waits in the exception block....

Sometimes this happens for the same document twice, and sometimes it just
happens for a different doc, different sequence!! I tried to run the same on
a directory containing only that doc and it works fine.. but when i run it
on an ancestor, then the crash dialog appears.... Any insights??
You've lost me on what an "ancestor" might be? If it's happening with specific
documents, I'd suspect document corruption. And I'd also expect it to happen
in the UI.

When Word (2002/2003) recovers, you generally get a list of files that were
open when it went down (left side of Word window). And when you hover the
mouse over such an entry, a drop-down arrow should appear. Click this. Is
there an entry about "Repairs" active in the menu list for the file you were
trying to open when the crash occurred?

In any case, you do have to consider the fact that you MIGHT encounter damaged
documents that will bring Word down. And there's no way to suppress all
"alerts" in the Word app. This is one big reason why MS says one should not
automate Office apps on a server. There is a KB article on msdn, written for
VB6, that describes how to dismiss messages when automating Office apps.
Basically, what it tells you to do is set a time limit, and if there's no
reaction from the application within this time, you use SendKeys(!) to dismiss
any dialog box that's holding things up. Not particularly elegant...
As far as i have used .NET, there's only an equivalent of CreateObject,
which uses the ProgId - "Word.Application".. Will research this though......
If you do come up with an equivalent of GetObject, I'd be interested in what
it is :)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
G

Guest

You've lost me on what an "ancestor" might be? If it's happening with
specific
documents, I'd suspect document corruption. And I'd also expect it to happen
in the UI.

An ancestor as in i am considering the directory structure as a tree
hierarchy and the parent, grand parent... and so on ancestors.. :)... And
now i have figured out that the problem is occuring for for some documents
and not during all my runs.. but on some application runs only.....
When Word (2002/2003) recovers, you generally get a list of files that were
open when it went down (left side of Word window). And when you hover the
mouse over such an entry, a drop-down arrow should appear. Click this. Is
there an entry about "Repairs" active in the menu list for the file you were
trying to open when the crash occurred?
In any case, you do have to consider the fact that you MIGHT encounter damaged
documents that will bring Word down.

The whole purpose of my application is to figure out the corrupted documents
that are critical, i.e. that crash Word on open and close of documents....
:-(
And there's no way to suppress all
"alerts" in the Word app. This is one big reason why MS says one should not
automate Office apps on a server. There is a KB article on msdn, written for
VB6, that describes how to dismiss messages when automating Office apps.
Basically, what it tells you to do is set a time limit, and if there's no
reaction from the application within this time, you use SendKeys(!) to dismiss
any dialog box that's holding things up. Not particularly elegant...

Thx.. i am looking into the same right now... if i could get this to work,
then my life is made..... right now, i am timing out and killing the Word
process and skipping the documents that cause dialogs, such as password.....
If you do come up with an equivalent of GetObject, I'd be interested in what
it is :)

Sure... only if i could find it... did some initial search on this... not
very hopeful.. but i am not abandoning this...

Thanks and Regards,
Laks
 
C

Cindy M -WordMVP-

The whole purpose of my application is to figure out the corrupted documents
that are critical, i.e. that crash Word on open and close of documents....
:-(
If you get the timer part worked out, I'd think you might use the Windows API
to get the "handle" of the dialog box being displayed, so that you could read
the title off it, in order to know what kind of message you're getting?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top