Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    general question about Free();

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 293 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 09/05/2009 at 12:24, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   r11 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Hi there, i just like to know where, why and in which case i should need Free(); or GeFree(); What exactly happens if i dont use it, for example within an objectplugin? I am using this:
      Vector *pnrm = ToPoly(res)->CreatePhongNormals(); and the manual tells to use GeFree();

      Is it a question of filling up the memory with unneccessary data??

      thanks for clarifying 🙂

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 09/05/2009 at 12:34, xxxxxxxx wrote:

        Hi, with GeAlloc you allocate a range of memory which is available until you call GeFree. If you dont free allocated memory it is a memory leak becaue you wasted memory until you end the app. (your OS will clear the range). So if the documentation tells you to use GeFree - do it, otherwise you get problems (or your customer).

        Look for "malloc and free" which is a C command and is similar to GeAlloc and GeFree (or maybe they are exactly the same, they just redirect the command).

        In your case..

        > <code>
        > Vector *pnrm = ToPoly(res)->CreatePhongNormals();
        > /* do what you want */
        > GeFree(pnrm);
        > </code>

        Its similar to gNew and gDelete. So just pair these commands and you will get no problems.

        bye, shawni

        edit: See "Debug information" in the C++ SDK Documentation with information how to detect memoryleaks.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 09/05/2009 at 13:03, xxxxxxxx wrote:

          And keep in mind 'ownership'. If you allocate an object and insert into a document:

          BaseObject* obj = BaseObject::Alloc(Ocube);
          if (obj) doc->InsertObject(obj, NULL, NULL, FALSE);

          Then doc now handles freeing the object and you shouldn't attempt to free it yourself. To free it yourself, you must remove it from the document list:

          obj->Remove();
          BaseObject::Free(obj);
          obj = NULL;

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 09/05/2009 at 14:18, xxxxxxxx wrote:

            thanks! i guess i'll have to add some of those now 😉

            1 Reply Last reply Reply Quote 0
            • First post
              Last post