User.fxg giving VB Out of Memory error while programming

Hi, I've got a wacky issue going on in VB that hopefully someone knows how to solve:

System: DeltaV Version 14.3.1 LTS (upgraded from 13.3.1), running DeltaV Operate

I am trying to add some code to a User.fxg file from a Client site. I had already added some code to this previously, but now when I go to add a new variable/function name I get an "Out of Memory" error.

After a bunch of searching I learned that VB has a hard limit of 32,000 unique identifiers per project. This includes variable names, function/sub names, forms/form objects, etc.

I can Dim new variables that reuse variable names from other functions/subs/etc, because they are not unique, but get the above error if I try to make a new name.

The solution seems simple at first glance: delete some existing code or move it to a new project.

Here's the kicker: this user.fxg does not currently have 32,000 unique items in it. If I delete 100 variables from the file then try to add a new one I get the same error. (Yes, I did compile, save, close, and reopen after the deletion)

Opening the User.fxg in notepad reveals some additional insights: Deleted variables are not being cleared for reuse by the compiler, and there are whole swaths of identifiers just not being used anywhere that I can find like "Variable28474" and "Variable28475"

I have verified that this same issue exists in the site User.fxg file from 4 years ago.

I have also tested on a fresh User.fxg file, that if I enter:

Dim iHateThisError

And then delete it, I can still find "iHateThisError" in the user.fxg file if I open it with notepad. This tells me that these variable names are being stored for the lifetime of the project, and that something, somewhere has inserted thousands of "Variable#" variables at some point along the way that I can't seem to purge.

Edit because the rest of this got lost when I posted:

I have been able to import everything into a clean user.fxg file and the "Variable#"s don't carry over, but I also need to transfer any global variables/color tables/etc. to the new file too, but I don't know an easy way to do that.

Does anyone have any insights as to how to fix or at least prevent this?

4 Replies

  • I don't know if this is the case or not, but if you have the file open on any machine when you save a change, the old code is still in the file as a second copy (this is why sometimes graphics double in size or half in size when a change is made). In this case, make sure only one machine has the file open at a time. It seems like you might be pretty experienced, so that's not likely the case, but just tossing it out there.

    The second part, I might be able to shed some light on. It is possible to copy and paste objects between files (including ones you can't select in the normal operate window). You can write VBA using the .SelectObject, .Copy and .Paste methods. For example Me.rct101.SelectObject, Me.Copy, TargetGraphicName.Paste. Using an intermediary regular graphic and you can copy everything to it, load your other user.fxg and then copy everything into the new one.

    Hope this might help a bit.

    Matt
  • In reply to Matt Forbis:

    I don't know if this is the case or not, but if you have the file open on any machine when you save a change, the old code is still in the file as a second copy (this is why sometimes graphics double in size or half in size when a change is made). In this case, make sure only one machine has the file open at a time. It seems like you might be pretty experienced, so that's not likely the case, but just tossing it out there.

    I'm pretty sure this is not what's happening. I do see it double in size when I save (even when only open on the one machine; all files are local instead of centralized anyways), then it reverts back when I close operate.

    The second part, I might be able to shed some light on. It is possible to copy and paste objects between files (including ones you can't select in the normal operate window). You can write VBA using the .SelectObject, .Copy and .Paste methods. For example Me.rct101.SelectObject, Me.Copy, TargetGraphicName.Paste. Using an intermediary regular graphic and you can copy everything to it, load your other user.fxg and then copy everything into the new one.

    This is something I hadn't thought of, but I'll give it a try.

    Thanks

  • In reply to Matt Forbis:

    This seems to be an effective workaround. I have made an empty graphic with these scripts (procedure is in the script comments)

    '1 - Before starting, export all script modules, classes, forms, etc. from the current user.fxg,
    ' and make note of all external references. Then back up the existing user.fxg file.
    '2 - Run "moveToTransfer()"
    '3 - Save this graphic
    '4 - Close Operate
    '5 - Copy clean User.fxg from C:\DeltaV\iFix\PIC to the active PIC directory
    '6 - Open Operate and re-open this graphic
    '7 - Run "moveToNewUserFXG()"
    '8 - Re-import all scripts back into user.fxg, and re-add all external references

    'This function will transfer all page level objects (variables, color/threshold tables, etc.)
    'from the current User.fxg to this page.
    Private Sub moveToTransfer()
    Dim objVar As Object
    For Each objVar In User.ContainedObjects
    objVar.selectobject True
    User.Copy
    Me.Paste
    Next objVar

    End Sub

    'This function will transfer all page level objects (variables, color/threshold tables, etc.)
    'from the current User.fxg to this page
    '
    Private Sub moveToNewUserFXG()
    Dim objVar As Object
    For Each objVar In Me.ContainedObjects
    objVar.selectobject True
    Me.Copy
    User.Paste
    Next objVar

    End Sub

    Thanks again for the tip on copying objects. Hopefully this can help anyone who runs into this same issue in the future.

  • In reply to Ryan Black:

    Glad you got it figured out!