Results 1 to 9 of 9

Thread: What's going to happen if not releasing kernels

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    20

    What's going to happen if not releasing kernels

    I wonder if there is something bad about not releasing cl_program and cl_kernel on a gpu device. At the end of my program I do release cl_command_queue and cl_context, but I don't release those former objects. Will this affect anything next time I use the gpu?

  2. #2
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: What's going to happen if not releasing kernels

    Nothing terrible will happen, but it's a good practice to always clean up all resources.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  3. #3
    Junior Member
    Join Date
    Aug 2011
    Posts
    20

    Re: What's going to happen if not releasing kernels

    Okay. Thanks. I'm just wondering if I really need to because it requires a decent amount of work to find the right place to release kernels. (I'm implementing a compiler that generate OpenCL if you wonder why it's hard.)

  4. #4
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: What's going to happen if not releasing kernels

    If you are using C++ you may want to use smart pointers to delegate the choice of when to release the kernels.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  5. #5
    Junior Member
    Join Date
    Aug 2011
    Posts
    20

    Re: What's going to happen if not releasing kernels

    Will using smart pointers increase the runtime of the application?

  6. #6
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: What's going to happen if not releasing kernels

    The cost of smart pointers tends to be very small. See Boost shared_ptr for example.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

  7. #7
    Junior Member
    Join Date
    Jan 2011
    Posts
    29

    Re: What's going to happen if not releasing kernels

    Not releasing CL objects will result in memory leaks. In this case, the program would leak a lot more than just the kernel-

    Even though the context was released by the main program, since the kernel was not released, the retain count on the context would not be zero (the kernel has a retain on the program, which has a retain on the context), so the context would not be deallocated.

  8. #8
    Junior Member
    Join Date
    Aug 2011
    Posts
    20

    Re: What's going to happen if not releasing kernels

    Quote Originally Posted by ajs2
    Not releasing CL objects will result in memory leaks.
    Leak until my application is terminated or until I reboot my machine?

  9. #9
    Senior Member
    Join Date
    May 2010
    Location
    Toronto, Canada
    Posts
    845

    Re: What's going to happen if not releasing kernels

    The leak will only persist until your application is terminated. Since the case you described was at program termination I didn't mention leaks because there will be none.
    Disclaimer: Employee of Qualcomm Canada. Any opinions expressed here are personal and do not necessarily reflect the views of my employer. LinkedIn profile.

Similar Threads

  1. Releasing cl_event s
    By giridhart in forum OpenCL
    Replies: 1
    Last Post: 07-20-2012, 08:31 AM
  2. Replies: 5
    Last Post: 04-14-2010, 10:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •