Re: Limitation with ActiveExplorer Selection?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ken Slovak - [MVP - Outlook] (kenslovak_at_mvps.org)
Date: 07/21/04


Date: Wed, 21 Jul 2004 08:44:06 -0400

There are a lot of factors involved, such as system resources and overall
RAM and virtual memory size. I've seen loops that worked correctly on my dev
machines cause out of memory errors on client's machines because of that.
There's a long-standing bug in how Outlook handles iterating collections of
items in loops. It creates internal variables that aren't released until
after the procedure exits and it gets worse the more dot operators you use,
since Outlook creates internal variables for each suboperator in the dots.
That's why using CDO 1.21 code works for loops like that, it doesn't create
those internal variables and can handle looping over much larger collections
than Outlook code can.

As far as specific limits on Selection, there aren't any hard and fast
rules. It just seems to break at some point.

-- 
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"John Riddle" <JohnRiddle@discussions.microsoft.com> wrote in message
news:57012B59-C5DD-4FC7-9B30-ED028B05E58E@microsoft.com...
> In my version of Outlook (2003), when I select a large number of items for
processing, I generally run into memory problems after a couple hundred or
so. However, I can very easily select several thousand and get a count
(Selection.Count). I can't understand at all why he would be having a
problem with that.
>
> Also, even if I only select a few dozen at a time and loop through them
with a For...Next loop such as:
>
> Dim candFolder As MAPIFolder
> Set candFolder = Application.ActiveExplorer.CurrentFolder
> If candFolder.DefaultItemType = olContactItem Then
> strJobTitle = "Manager"
> strDepartment = "IT"
> For Each cand In Application.ActiveExplorer.Selection
>        cand.JobTitle = strJobTitle
>        cand.Department = strDepartment
>        cand.Save
>        Set cand = Nothing
> Next
> strJobTitle = ""
> strDepartment = ""
> End If
> Set candFolder = Nothing
>
> This code produces "Out of memory." errors if more than a couple hundred
items are selected AND oddly enough, if I select only a couple dozen and
process them, then select a couple dozen different items and process them
and so on in stages like this, I still get memory errors after a few
hundred. I'm convinced that processing items using the Selection collection
has memory problems.
>
> Can you re-create this scenario Ken?
>
> John


Relevant Pages

  • Re: "Mastering C Pointers"....
    ... all means go ahead and dive right into the C language. ... Memory is a separate unit which just stores bits. ... A pointer at the hardware level _is an integer_. ... since loops make your logic more much ...
    (comp.lang.c)
  • Re: Limitation with ActiveExplorer Selection?
    ... I've seen loops that worked correctly on my ... > machines cause out of memory errors on client's machines because of that. ... > since Outlook creates internal variables for each suboperator in the dots. ...
    (microsoft.public.outlook.program_forms)
  • Re: Best Performance File Compare: MD5/SHA1 or Byte-by-Byte Checking?
    ... you might want to use the method that loops ... the entire contents of the two files into memory. ... comparing the chunks, you are going to make the process much more efficient. ... What about MD5? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: "Mastering C Pointers"....
    ... > Memory is just a big array of bytes again. ... > (If you're not totally familiar with loops in general, ... My point was that for and while loops compile down to ... > organize this enormous stream of instructions ...
    (comp.lang.c)
  • Re: Outlook out of memory after installing SP2
    ... In the german access newsgroup there are people which have similar problems with access after installing sp2! ... The message I get is: "Outlook doesn't have ... enough memory to start operation of services. ... Should I reset my system to a point before the SP2 installation? ...
    (microsoft.public.outlook.general)