0 Replies Latest reply: Dec 15, 2011 10:47 AM by 845971 RSS

    Memory managment for classes inheriting from PObject.

    845971
      Hey, I have a class that inherits form PObject, and im not sure how to manage the memory for it. In profiles, it shows up as leaks, so im sure im doing something wrong.
      First, how do i figure our what type of PObject it is (Transient or Persistent)

      .typ file looks like this:
      CASE=LOWER
      TYPE ist
      TYPE istt

      table looks like:
      desc ITEM;
      Name Null Type
      .. other types ...
      STAT_ARRAY STAT_VA()


      when inserting in code:
      std::vector<ist*> stats;
      for (...)
      ist* itemStatType = new ist;
      itemStatType->setstat_id(123);
      itemStatType->setstat_value(123);
      stats.push_back(itemStatType);

      static std::string sqlTypeName("STAT_VA");
      setVector(statement, 16, stats, "SCHEMA", sqlTypeName);

      statement->execute()

      and we never delete what we have new'ed, under the assumption that occi has taken ownership.
      If this is not correct, when is the correct time to delete the values? (safely?) After statement->execute() ?

      Edited by: anderse on Dec 15, 2011 8:47 AM