Friday, November 22, 2024

Using Discardable MboSets in Maximo Automation Scripts

 

I would say about 90 percent of the time that, in Maximo code, when we access an MBO set, we just navigate through it, first record to last. Usually it is to retrieve a certain value for calculation or some other reason. This is a sample of what that code looks like:

    assetMboSet = mbo.getMboSet("ASSET")

    curMbo = mbo.moveFirst()
    while curMbo != None:
        # Read some value from the mbo
        curMbo = mbo.moveNext()

This is pretty straight forward code but let’s look at the impact of this code in reference to performance. Whenever you access an MboSet, Maximo automatically caches the data as it assumes that you will probably want edit it. However, if you only just want to read through a MboSet, then placing the data in cache means it is taking up memory space that you do not need to take up. A better approach for MboSets that you plan on just reading through (no updates), is to make the MboSet “Discardable.” This tells Maximo to not place the data in the cache, freeing up memory. The code to do this is:

    assetMboSet = mbo.getMboSet("ASSET")
    assetMboSet.setFlag(MboConstants.DISCARDABLE, true)
    curMbo = mbo.moveFirst()
    while curMbo != None:
        # Read some value from the mbo
        curMbo = mbo.moveNext()

As you can see it only take one line of code but can have a big impact on memory usage. One important thing to note is that a “Discardable” MboSet is always read-only. If you are struggling with JVM memory availability in your Maximo environment, this is an easy way to help free up some of it.

Happy Coding

No comments:

Post a Comment