Open topic with navigation

TIBCO Rendezvous® 8.8.0

# TibrvMsg::markReferences()

Method

## Declaration

    TibrvStatus markReferences();

## Purpose

Mark references in this message.

## Remarks

Extracting pointer data from a message field creates a snapshot of that data. The snapshot remains associated with the message until the program destroys the message. However, in rare situations snapshots can accumulate within a program, causing unbounded memory growth. This method gives programs explicit control over snapshot references; by clearing references, the program declares that it no longer needs the references that arise as side effects of calls that get a message field.

For example, consider a program fragment that repeatedly sends a message, modifying fields within a nested submessage before each send call. Each call to extract the nested message produces a snapshot reference. By surrounding the get operation with a mark and clear pair (with the clear call occurring at any time after the get call), the program releases the reference, which helps control memory usage.

    void TimerCallback::onTimer(TibrvTimer* timer)
    {
        TibrvMsg* msg = (TibrvMsg*)timer->getClosure();
        msg->markReferences();
        TibrvMsg submsg;
        msg->getMsg("foo",submsg);
        ...
        msg->clearReferences();
        msg->setSendSubject(some_subject);
        /* send a message */
        transport.send(*msg);
    }

Every call to TibrvMsg::markReferences() must be paired with a call to TibrvMsg::clearReferences(). It is legal to mark references several times, as long as the program eventually clears all the marks. To understand this idea, it is helpful to think of get and mark as pushdown operations, and clear as a pop operation. Mark and Clear References illustrates that each clear call deletes snapshots back to the most recent mark.

Figure 212: Mark and Clear References

Unless a program explicitly marks and clears references, references persist until the message is destroyed or reset.

## See Also

Validity of Data Extracted From Message Fields

Deleting Snapshot References

TibrvMsg::clearReferences()

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO Rendezvous®

Copyright © 1997-2025. Cloud Software Group, Inc. All Rights Reserved.