MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 17th, 2002, 07:52 AM   #1
MrExcel
.
 
MrExcel's Avatar
 
Join Date: Feb 2002
Location: Akron, Ohio USA
Posts: 789
Default

How does a PivotCache get deleted from memory?

I have a procedure that defines a pivot cache and builds two pivot tables. Another procedure modifies the pivot tables. When that procedure is complete, it clears the pivot tables with
Code:
    PT.TableRange2.Clear
    PT2.TableRange2.Clear
There doesn't seem to be anyway to explicity clear the pivot table cache. I initially thought I didn't have to worry about it, but now I am starting to see memory errors after a day of running these reports.

After deleting the above pivot tables, this code seems to indicate that the PivotCache is gone. There are no messages generated from this:
Code:
    For Each pc In ActiveWorkbook.PivotCaches
        MsgBox pc.MemoryUsed
    Next pc
Rather than leave this to chance, I would like a way to explicity clear the memory from the pivotcache.

Bill

_________________
MrExcel.com Consulting

[ This Message was edited by: MrExcel on 2002-05-17 06:53 ]
MrExcel is offline   Reply With Quote
Old May 17th, 2002, 08:10 AM   #2
MrExcel
.
 
MrExcel's Avatar
 
Join Date: Feb 2002
Location: Akron, Ohio USA
Posts: 789
Default

I added Debug.Print Application.MemoryUsed at the beginning and end of the report.

Even though there are no PivotCaches left in ActiveWorkbook.PivotCaches, I'm clearly taking up a significant higher amount of memory.

Any ideas on how to clear the MemoryUsed?
__________________
Preview my latest book for Free
MrExcel is offline   Reply With Quote
Old May 17th, 2002, 08:22 AM   #3
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

Is the following of help?


Sub Proc06_DisplayPivotCacheProperties()
Dim Pivot1 As PivotTable
Set Pivot1 = Worksheets("Pivot").Pivottables("Pivot1")
With Pivot1.PivotCache
MsgBox "Memory Used: " & .MemoryUsed
MsgBox "Record Count: " & .RecordCount
MsgBox "Refresh Date: " & .RefreshDate
MsgBox "Refresh Name: " & .RefreshName
MsgBox "Connection: " & .Connection
'The following sets the pivottable to refresh on file open.
.RefreshOnFileOpen = True
'The following refreshes the pivottable cache.
.Refresh
End With
End Sub


Pulled from:

http://www.microsoft.com/exceldev/articles/movs104.htm
__________________
Regards,
Nate Oliver
Microsoft Excel MVP
Nate's Excel Blog
NateO is offline   Reply With Quote
Old May 17th, 2002, 09:10 AM   #4
MrExcel
.
 
MrExcel's Avatar
 
Join Date: Feb 2002
Location: Akron, Ohio USA
Posts: 789
Default

I saw that and was able to ascertain the memory being used by the PivotCache. You'll notice they don't address clearing the PivotCache at all.

I am tempted to try creating the pivot table in a temporary workbook. Then, after creating the report, I could close that temporary workbook, which should remove any memory used by that temporary workbook...
__________________
Preview my latest book for Free
MrExcel is offline   Reply With Quote
Old May 17th, 2002, 02:29 PM   #5
NateO
Legend
 
NateO's Avatar
 
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
Default

The temp file may be the way to go, I'm starting to get the impression that the pivotcache object is read-only. A few findings:

The following link has a lot of useful object property details, including .optimizecache but I didn't notice anything regarding deletion.

http://msdn.microsoft.com/library/de...pivotcache.asp

I did stumble into the following.

Per Microsoft:

"Remarks
If the PivotTable cache isn?t referenced by a PivotTable object, the PivotTable cache is automatically deleted before the workbook is saved."

http://216.239.39.100/search?q=cache...&hl=en&ie=UTF8

Section: Add method as it applies to the PivotCaches object.

From this I might surmize that if one deletes a pivot table, the cache is deleted and until then it's out there.

Perhaps XL can be of assistance.
_________________
Cheers, NateO

[ This Message was edited by: NateO on 2002-05-17 13:34 ]
NateO is offline   Reply With Quote
Old May 17th, 2002, 04:31 PM   #6
Mark W.
MrExcel MVP
 
Join Date: Feb 2002
Location: Austin, Texas USA
Posts: 11,654
Default

What happens when you do this...

ActiveSheet.PivotTables("PivotTable1").SaveData = False
Mark W. is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 01:27 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes