I have been working with Win32::OLE mostly successfully, but with numerous hurdles that I will summarize below. Perhaps you might have ideas for workarounds/solutions.

1. COM chews up a lot of memory and pegs the CPU. Not an issue for short processes, but for long processes, the memory heap keeps on building up, and then eventually quits... I get a funky "Smart Heap Library" error -- obviously not very "Smart," Of course, the computer also gets extremely sluggish (does Windows had a 'nice' equivalent for COM?). So, I am trying to FreeUnusedLibraries and Uninitialize (methods in Win32::OLE) and re-initialize, but am not sure if it is helping.

2. Seems like VB/COM has a latency that the OS doesn't seem to respect. Here is what happens --

a. do something with COM b. do something as a result of #1

One would expect that #b above would be carried out ONLY when #a above has cleanly ended. Well, apparently not. #a is started, the OS thinks it is done, and passes command to #b, but #a is still chugging along. These race conditions are unpredictable. I have been experimenting with

Win32::OLE->FreeUnusedLibraries(); Win32::OLE->SpinMessageLoop(); sleep 5;

but, as I said, these race conditions are unpredictable. Typically, I encounter this when I delete something in a directory 'dir' (#a above), and then do something (#b) that expects an empty directory 'dir', but #b comes back and says that the directory 'dir' is still not empty. I can change sleep 5 to sleep 10, but never any guarantee.

3. File/folder permissions. This is a strange one. I get an erro if I do the following --

a. mkdir(folder) b. put something in that folder c. do something with stuff put in #b above or confess

The error is akin to "stuff doesn't exist" even though it is clearly there, and file tests pass successfully. My process croaks and I restart. Since this time the folder already exists, I don't encounter the error. This happens consistently, and without any intervening changes to the permissions. I've got around this by pre-creating folders, but then I can't use any logic that depends on existence or absence of folders.

--

when small people start casting long shadows, it is time to go to bed

In reply to cpu, memory, and permissions issues with Win32::OLE by punkish

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.