Limits for Word - Cache

S

Scott

Hello:

In Word 2002 Help, under "Limits for Word" the following two cache default
limits are mentioned:

Default cache size
64 kilobytes (KB)
Default bitmap cache (bitmap memory)
1 MB



Can someone tell me how to change these defaults? I suspect that in large
documents, it may be beneficial to increase these for optimal performance
and to avoid crashes.

Also, the limits state that the file size limit is 32 Mb. I know that this
is not the case, as I have a number of Word files that work, albeit slowly
and painfully with a few of them, at much larger sizes, up to 200 Mb. Just
try pasting a few (unlinked) Excel tables with Paste Special...Excel
Worksheet Object into a Word doc. I have a one-page doc with three such
tables in it that is over 150 Mb or about 50 Mb for each small Excel table
(7 Rows X 9 Columns), pasted in that way.

If anyone could help with setting the default cache sizes, I'd appreciate
it.

Scott
 
J

Jay Freedman

Hi, Scott,

You can use the Registry Options macro in the Support9.dot template
(which you may find on the Office CD) as described near the end of the
article at http://support.microsoft.com/?kbid=239431. However, that
article is for Word 2000 and there is no equivalent article for Word
2002 -- nor is there a version of Support9.dot for any later version
of Word. This macro puts Cache and BitMapMemory values under the
registry key
HKEY_CURRENT_USER\Software\Microsoft\Office\9.0\Word\Options, and I
don't believe they have any effect on Word 2002 (a.k.a. Word 10.0) or
Word 2003 (Word 11.0).

Besides that, my colleague John McGhie has written
(http://www.techknowledgecorp.com/public/jmcg.html) that these
settings don't have any measurable effect on performance, and that
total available memory is the determining factor.

As for the 32 MB maximum, that applies only to text and doesn't
include graphics and embedded objects. Total file sizes certainly can
exceed 32 MB.
 
S

Scott

Hi Jay:

Thanks for the reply. You're correct, there is no cache setting in Word 10
via Support.dot. The reason that I ask is that I have a file that contains
a lot of embedded OLE from Excel, mainly in the form of bitmaps. When
editing the file Word continuously complains that it hasn't got enough
memory to complete often simple things. Word frequently crashes and if
recovery is selected the recovery file process produces about 60 separate
files, all of which have unlinked and mis-sized bitmap graphic elements.
There seems to be a maximum number of times that I can save the document
before it crashes. It will very likely crash if I save and try to page
scroll before save is finished, which takes several seconds. Often when
editing, if I have saved about 7-10 times, word will give the error message
"Low on Memory, save your work now." Yet looking in the system performance
under task manager, memory usage is usually in the 400 Mb area, with about
400 mb of physical memory available ( of 1 GB), virtual limit is 2.5 GB,
available system cache is 600 mb and peak usage is in the high 400 mb usage.
There is no lack of memory. I have all the SPs and security updates are
also current for Word, Office and Windows XP. What is the problem? I hope
that you can help.

Scott
 
J

Jay Freedman

Hi, Scott,

You could try adding the Cache and BitMapMemory values under the
registry key
HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Word\Options
to see if it helps. If Word doesn't use them, at least it won't do any
damage.

The "out of memory" error is often bogus, just an indication from Word
that "something is wrong but I don't know what." One thing I've
noticed is that an excessive buildup of .tmp files can cause problems
of this kind. Word creates at least one .tmp file for each OLE object
that you edit during the session
(http://support.microsoft.com/?kbid=211632), and it seems to run out
of file handles or something, somewhere in the vicinity of 100 files.
I once edited a math book manuscript that had hundreds of Equation
Editor equations per chapter; I had to keep an Explorer window open
behind Word with its status bar visible so that I could shut down Word
when there were 90 to 95 .tmp files, or else it would crash shortly
afterward.

My personal opinion is that OLE is a swamp full of alligators, and
it'll never be adequately drained. <g>

Scott said:
Hi Jay:

Thanks for the reply. You're correct, there is no cache setting in Word 10
via Support.dot. The reason that I ask is that I have a file that contains
a lot of embedded OLE from Excel, mainly in the form of bitmaps. When
editing the file Word continuously complains that it hasn't got enough
memory to complete often simple things. Word frequently crashes and if
recovery is selected the recovery file process produces about 60 separate
files, all of which have unlinked and mis-sized bitmap graphic elements.
There seems to be a maximum number of times that I can save the document
before it crashes. It will very likely crash if I save and try to page
scroll before save is finished, which takes several seconds. Often when
editing, if I have saved about 7-10 times, word will give the error message
"Low on Memory, save your work now." Yet looking in the system performance
under task manager, memory usage is usually in the 400 Mb area, with about
400 mb of physical memory available ( of 1 GB), virtual limit is 2.5 GB,
available system cache is 600 mb and peak usage is in the high 400 mb usage.
There is no lack of memory. I have all the SPs and security updates are
also current for Word, Office and Windows XP. What is the problem? I hope
that you can help.

Scott
 
S

Scott

Hi Jay:

Whoever told you that those parameters made no difference never worked with
truly professional sized documents. Apparently those parameters are still
in Word 2002 AKA 10. I did as you suggested and added the parameters
CacheSize and BitMapMemory at string values "1024" and "4096" respectively.

It made a huge difference!!!!! I've saved the file now over 50 times with
link updates in between each save. It just won't crash now. Before, it
crashed after about 10-15 saves. Also, on opening, it previously took 2
minutes to finish the initilization while word slowly scrolled through the
~200 pages, probably updating the bitmats. It now finishes that in a
fraction of a second.

I haven't been able to make it crash, which is absolutely amazing. Whoever
told you that those parameters didn't do anything, never tried them on a
truly professional sized file.

One problem remains. You've been so good at helping, I hope that you can
suggest a fix for this one as well. I still cannot update all the linked
objects at once without the process blowing up (not a word crash). When I
do Edit .. Links and mark all the links (all manual update), then do an
"Update Now" it craps out partway. When it does it says that "Objects in
this document contain links to files that cannot be found.": If the file is
saved after that, many of the links will be removed and unlinked bitmaps
will remain. This is not a desired result.

I can't find a way to update all the links at once that works. Do you have
a fix for this, Mr. Wizard? Thanks in advance for any help you can give!!

Sincerely with many thanks for the help you've given already,

Scott

Whoever decided to remove those
Jay Freedman said:
Hi, Scott,

You could try adding the Cache and BitMapMemory values under the
registry key
HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Word\Options
to see if it helps. If Word doesn't use them, at least it won't do any
damage.

The "out of memory" error is often bogus, just an indication from Word
that "something is wrong but I don't know what." One thing I've
noticed is that an excessive buildup of .tmp files can cause problems
of this kind. Word creates at least one .tmp file for each OLE object
that you edit during the session
(http://support.microsoft.com/?kbid=211632), and it seems to run out
of file handles or something, somewhere in the vicinity of 100 files.
I once edited a math book manuscript that had hundreds of Equation
Editor equations per chapter; I had to keep an Explorer window open
behind Word with its status bar visible so that I could shut down Word
when there were 90 to 95 .tmp files, or else it would crash shortly
afterward.

My personal opinion is that OLE is a swamp full of alligators, and
it'll never be adequately drained. <g>
 
J

Jay Freedman

Hi, Scott,

I'm really happy you got a positive result. It'll go into my bag of
tricks. You just never know what'll work and what won't... there are
so many variables, such as just how many links there are and exactly
what they link to.

Don't ever tell John McGhie, the MVP whom I quoted, that he never
worked with "truly professional sized documents" -- that's all he
does, including some multi-thousand-page monsters. Anyway, I think
John was writing about editing/saving *speed* rather than stability
when he said the cache doesn't make any difference.

For your remaining problem, there may be a solution. Can you get
through updating the whole document if you only update part of it at a
time, say 100 links, then save, and repeat ad nauseam? If so, we can
probably automate that with a macro.

Scott said:
Hi Jay:

Whoever told you that those parameters made no difference never worked with
truly professional sized documents. Apparently those parameters are still
in Word 2002 AKA 10. I did as you suggested and added the parameters
CacheSize and BitMapMemory at string values "1024" and "4096" respectively.

It made a huge difference!!!!! I've saved the file now over 50 times with
link updates in between each save. It just won't crash now. Before, it
crashed after about 10-15 saves. Also, on opening, it previously took 2
minutes to finish the initilization while word slowly scrolled through the
~200 pages, probably updating the bitmats. It now finishes that in a
fraction of a second.

I haven't been able to make it crash, which is absolutely amazing. Whoever
told you that those parameters didn't do anything, never tried them on a
truly professional sized file.

One problem remains. You've been so good at helping, I hope that you can
suggest a fix for this one as well. I still cannot update all the linked
objects at once without the process blowing up (not a word crash). When I
do Edit .. Links and mark all the links (all manual update), then do an
"Update Now" it craps out partway. When it does it says that "Objects in
this document contain links to files that cannot be found.": If the file is
saved after that, many of the links will be removed and unlinked bitmaps
will remain. This is not a desired result.

I can't find a way to update all the links at once that works. Do you have
a fix for this, Mr. Wizard? Thanks in advance for any help you can give!!

Sincerely with many thanks for the help you've given already,

Scott

Whoever decided to remove those
 
S

Scott

Hi Jay:

On the first subject, I didn't mean to be negative, but the bitmap size
speeds editing by a lot for this document as well as improving stability.
I've had many huge documents with no problems like this one, this is an
extremely linked document with 200 pages and on each page from 1 to 25
bitmaps - all linked to Excel..

I wrote a macro to try to do the update, but my vocabulary of VB methods is
not extensive. I did the following:

Sub UpdateLink()
'
' UpdateLink Macro
' Macro recorded 12/22/2003 by Scott Brown
'
Selection.HomeKey Unit:=wdStory
ActiveWindow.View.ShowFieldCodes = True
counter = 0
Selection.Find.ClearFormatting
With Selection.Find
.Text = "LINK Excel.Sheet.8 C:\\PPTFinal\\BOC_Fin.xls"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Do
Selection.Find.Execute
If Selection.Find.Found = True Then Selection.Fields.Update
If Selection.Find.Found = True Then counter = counter + 1
'
Loop While Selection.Find.Found = True
'
MsgBox "This procedure found " & counter & " links to BOC_Fin.xls"
Selection.HomeKey Unit:=wdStory
ActiveWindow.View.ShowFieldCodes = False
End Sub

It didn't work because when the bitmap is not shown in graphic mode
(ActiveWindow.View.ShowFieldCodes = True), the links are not updated. Also,
for some reason, the counter seems to count pages instead of links and it
stops on page 162, instead of going to the end. I don't know why and I
didn't debug further because it didn't work. I spent a little time looking
for the correct method to find the next linked object (in ShowFieldCodes =
False mode) but decided that the problem is likely memory related and I
started to pursue that in betweeen the pressures of getting the document
finished.

When this procedure is run twice, Word becomes unstable. The top of the
word frame with the document file name turns to garbage and the task pane
graphics stop being updated. After a few more manual "update links" word
declares that the link cannot be found. If it gives that statement when the
bitmap is shown, the link is deleted and the bitmap becomes static and
unlinked. This is clear evidence of a program bug - a memory leak. I've
done a lot of C/C++ and assembly language programing. This is real clear
evidence that some procedure is allocating memory and not releasing it until
you exit the program, even though the procedure is finished. I looked for
..tmp files being created, as you mentioned and couldn't find any except when
word or excel is opened.

I tried the update links on print under Tools > Options > Print Tab > Update
Links checkbox. If I do a print to PDF with the Acrobat plugin, the result
is garbage. All the page numbers in the TOC area are XI and all the page
numbers in the main document are either the same or they stop at some page
number and the remainder of the doc has the same page number on each page.
All the bitmaps beyond a certain point in the document are blank rectangles.
If I try to edit the document, ALL of the menu items for
Edit/View/Insert/Fomat/Tools/Table are grayed out. The document size drops
to ~9.5 Mb from its current ~59 Mb, likely from the missing bitmaps.. In
other words, that operation destroys the document.

If you can point me to a procedure that will cycle through the bitmaps, that
would be a good workaround. You can't change back to ShowFieldCodes = False
after finding the link in the procedure above because the selection is
broken when that step is taken, from trying it manually. Do you file bug
reports to the Microsoft development team?

Thanks for all your help.

Scott

Jay Freedman said:
Hi, Scott,

I'm really happy you got a positive result. It'll go into my bag of
tricks. You just never know what'll work and what won't... there are
so many variables, such as just how many links there are and exactly
what they link to.

Don't ever tell John McGhie, the MVP whom I quoted, that he never
worked with "truly professional sized documents" -- that's all he
does, including some multi-thousand-page monsters. Anyway, I think
John was writing about editing/saving *speed* rather than stability
when he said the cache doesn't make any difference.

For your remaining problem, there may be a solution. Can you get
through updating the whole document if you only update part of it at a
time, say 100 links, then save, and repeat ad nauseam? If so, we can
probably automate that with a macro.
 
J

Jay Freedman

Hi, Scott,

It isn't necessary to show field codes in order to find and update the
links. The .Find.Text code ^g will find a graphic, and then the
macro can check whether the found graphic is really a LINK field. As I
suggested before, this macro saves the document after each 100
updates.

Of course, I don't have your monster document to test the macro with,
so I'll have to leave that to you. I hope it works for you!

Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)

Sub UpdateLink()
Dim oRg As Range
Dim oFld As Field
Dim nCount As Long

Set oRg = ActiveDocument.Range
With oRg.Find
.ClearFormatting
.Forward = True
.Format = False
.Wrap = wdFindStop
.Text = "^g" ' graphic

Do While .Execute
oRg.MoveEnd unit:=wdCharacter, Count:=1
If oRg.Fields.Count > 0 Then
Set oFld = oRg.Fields(1)
If oFld.Type = wdFieldLink Then
oFld.Update
Sleep 100 ' give it 0.1 sec to update

nCount = nCount + 1
If nCount Mod 100 = 0 Then
ActiveDocument.Save
StatusBar = "Updated " & nCount _
& " fields"
End If
End If
End If

' prepare to look for next field
oRg.Collapse wdCollapseEnd
Loop
End With
End Sub
 
S

Scott

Hi Jay: (I sent the 450KB Zip attachment with the 3 test files to your
email address the newsgroup won't allow it)

I couldn't get back to this problem until today. Thanks very much. This
was quite helpful. After a few tweaks, the problem is close to solved. It
is a workaround, not a true solution as the automated functions in Word
should really work without all this mess. I would encourage you to report
this as a program bug to Microsoft developers.

In order for the procedure to run, I had to drastically increase the cache
allocation for word for bitmaps to 32,768 and simple cache to 4096. I
modified the code a little bit as well. Unfortunately, saving doesn't
release the memory leak. If it does crash, as it does with less cache, it
saves the unusable file and all the previous update links are for naught.
Without looking at the links it updates, it is not possible to see if it
worked right. Even now, running the procedure produced six "Error! Not a
valid link." I can assure you, all the links were valid previously.
Interestingly, if you look at the code the link is valid and if you re-paste
link it from Excel, the {code} does not change.

Following are just some of the problems that can happen:

1. Link Gone, Graphic Remains
2. Link & Graphic Gone {} code remains.
3. Linked Object Resized whether or not \* MERGEFORMAT is included in the {}
code
4. Linked Object property changed e.g. Manual Link changed to Automatic
5. Word crashes and the recovered document is total garbage (many files with
distorted graphics from the previous single document).

Increasing the Cache sizes has pretty much eliminated the crashing, but not
problems 1-4. These problems are lessened, however as well.

To optimize the performance of the update procedure, is better to save at
the start and optionally run again with a button or manually from the new
location. The sleep delay combined with the graphics search and the
increased cache all were necessary to make this work. Once it runs, the
menus in Word no longer work. If I do a system performance check with task
manager, it no longer shows the graphic of "CPU usage" and "Page File Usage"
I got a call from someone who asked me to look at some pdf that he sent me
and the Title block of Acrobat was full of garbage characters. Closing Word
solves the problem. There is clearly a severe memory leak in the procedure
in Word that updates bitmap graphic links. This may be the entire reason
that more cache is necessary. I hope that you report this to the Microsoft
developers.

The only problem with the graphic find is that not all my links are graphic,
although most are. My modified procedure takes care of that.

Second issue is the sleep delay. Even doing 10 links without that (for
example using the "Edit > Links >...Mark 10 links .. > Update Now Button"
method can sometimes cause some links to change in size, even with the \*
MERGEFORMAT parameter in the link statement. With the delay, the links
update without being changed in size.(I assume "Reset to Original Size."

I decided to try to reproduce the problem with a very simple example. I
took a simple Excel file with non-proprietary information in it. I copied
and pasted a section of it as a bitmap into a Word document, set it as
Manual and resized it. I then made about 300 copies of it, for a 300 page
document. I put a Table of Contents and page numbers in for good measure.
If I use the "Edit > Links > ...mark all ... > Update Now Button" the same
type of behavior happens. All the links turn to Error!.

I then took a copy of the file and ran the macro you gave me on it. After
42 updates, all the rest turn to Error!. The failure is not as complex as
when all the links are different and all the other issues with a real
document, but it fails just the same and in a way that your routine failed
in my document, even after I modified everything to work a bit better,
including only updating 25 at a time.

For your testing pleasure, I have attached the Excel and two Word Docs.
The -1 file is corrupted by the running of the update procedure. Note that
the links expect the Excel file to be at: C:\\Documents and
Settings\\Administrator\\My Documents\\Gamma Speed of Light.xls I did this
to facilitate your finding a solution for this problem. I hope that you can
find it.

I've spent way too much time on it and am now really tired of dealing with
this issue. I hope that you can be as helpful as you have been so far.

Sincerely

Scott
 

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