IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

I've been writing a bunch of SPRs recently about crashes in LotusScript, and I thought my findings might be of use to the folks here. I've found three things to avoid to prevent my code from crashing the client or server.

  1. Don't rely on LotusScript object reference counting and cleanup when the objects are defined in different script libraries (class X in library A contains an instance of class Y in library B). Use the Delete subroutine and statement to explicitly delete such objects. I've been being extra safe and doing that regardless of whether they're in the same library.
  2. Don't "redim preserve" arrays of objects.
  3. Don't delete an object from within its own method (directly or by calling another method).

Andre Guirard | 17 March 2010 08:25:33 AM ET | Home, Plymouth, MN, USA | Comments (8)


 Comments

1) Can you elaborate?
Erik Brooks | 3/17/2010 9:23:03 AM

Is #1 related to that circular reference problem you blogged about while back?

#2 sounds like a bug. I'm pretty sure we never do that but what's wrong there?

#3 sounds like it should throw a runtime error, but it makes sense that it shouldn't be happy in any case.

2) Umm
Bill | 3/17/2010 9:27:13 AM

1. I've seen numerous red-boxes in OO Lotuscript using complex objects (lists of objects of lists of objects) where the garbage collector gets confused and dies. I now no longer attempt to delete objects in memory - our software has to run across multiple versions and its almost guaranteed that the customer is running a version that has this error.

2. We use redim preserve a *lot* given that there's not another collections object that retains order - what do you recommend to do instead ? Or can you highlight how to check for low-memory situations (aside from using lsi_info() - itself a huge source of crashes)

3. Do people actually *do* that ? ;-)

The difficulty is that perhaps 90% of complex code out there in Domino is written using Lotuscript - and the language itself hasn't been updated since 4.6 time.

Its starting to show its age in a number of areas, not least:

- memory management (Where a Red-Box is your reward for straying close to the edge),

- no introspection (so that rules out writing test harnesses automatically),

- not even the ability to use the majority of C-API calls on OS/400 (no native 14-byte variable type to replace pointers with),

- a dangerously unreliable and unstable agent manager (where even if you *do* get an NSD, its almost impossible to figure out which agent and/or where AMGR failed),

- 64-bit platform issues (where lotuscript code works in 32-bit but crashes 64-bit servers)

- only the dangerous 'execute' method of dynamically loading classes. (And you have to use dynamic loading if you 'use..' more than 20+ libraries if you want your agent to load in under 2 minutes)

I wish this wasnt the case, but I would have to advise people to start avoiding Lotuscript going forward, given its long list of existing issues, and all the new exciting ones introduced with the recent failure of the 'getAllDocumentsByKey()' call.

It'd be great to knock some of these long-standing issues off the list, but even I have lost faith that some day they will.

---* Bill

{ Link }

3) Don’t "redim preserve" arrays of objects.
Henning Heinz | 3/18/2010 4:45:32 AM

I am also interested in the Redim Preserve topic.

I have not seen a red box for years and think IBM replaced that with something less entertaining!?

I also sometimes had a smile on my face when coroner quincy came around.

Those were the days.

4) How not to crash in LotusScript
Andre Guirard | 3/18/2010 9:53:41 AM

@Bill, instead of redimensionable arrays of objects, you could use linked lists; those seem to work well provided, as I said before, you don't forget that doubly-linked lists need to be "manually" deallocated. I've also had occasion to use fixed-size arrays with a counter telling how many elements are in use; if you run out of space you can have a linked list of records each containing an array.

I don't exactly know what the problem is with the arrays of objects, but I was seeing crash stacks involving them, which seemed to imply that the reference counting mechanism was off when, e.g. the array is made smaller and elements drop off the end, maybe the system doesn't notice that the reference went away. That's just a guess; I didn't investigate it in detail.

5) Thanks
Peter Presnell | 3/18/2010 8:29:06 PM

Thanks Andre for being proactive and sharing your insight into some of the causes of LotusScripr crashes. Like Bill I have largely given up hope that IBM will ever invest any time/effort to bring LotusScript into the 21st century. But I do hope that IBM may invest some time tracking down the causes of the issues with some of these things. Especially the weakness with Redim Preserve. There may be some alternatives for this but I would suggest it adds increasing complexity to a progeramming language whose greatest appeal has always been its simplicty.

6) #2
Erik Brooks | 3/22/2010 11:45:08 PM

@Andre - I'm confused. Are you sure that redim preserve on an array of objects causes a crash? Or was what you saw crashes that just happened to contain such code in them?

I'd really like to know a firm answer on that. It totally sounds like a bug. And if it's not something to be fixed then the Designer Help really should be updated to say something like "Don't use redim preserve on an array of objects, it may crash."

7) #6
Karsten Lehmann | 3/23/2010 7:06:39 AM

I'd rather have that bug fixed instead of the documentation changed. :-)

8) #1
Tasos Christidis | 4/9/2010 10:14:17 AM

#1 is so true: I have extensive bad experience from the resultset object when using ODBC. *Always* delete the object or even "Set result = Nothing" when you don't need it!!!

9) Redim preserve
Bruce Mackenzie | 9/10/2010 4:29:00 AM

I think the problem with Redim Preserve on objects is that Notes or Domino can run out of memory while doing it, causing a crash. There's nothing "functionally" wrong with it.

We had a problem with our intranet servers after upgrading to 8.5.1 64-bit, where one of our web agents that runs 50000 times a day would periodically crash the server. Often the crash would happen during redimming an object array, which ran the server out of memory. We got a hotfix that fixed it though...

 Add a Comment
Subject:
   
Name:
Comment:  (No HTML - Links will be converted if prefixed http://)
 
Remember Me?     Cancel

Search this blog 

Disclaimer 

    About IBM Privacy Contact