On 5/21/19 5:30 PM, Hamad Ahmed wrote: > As in my case, I have data residing on the GPU and the pointers to > it are kept on the CPU and I rely on them being garbage collected > when all references to it disappear. The GPU data is then freed up > inside the finalization function. So even though my program works on > a lot of data, its not on the CPU and the program overall doesn't > have a lot of register pressure so absence of black-holing registers > is hurting me. This is the wrong way to control the lifetime of data in a GPU. As we've seen many times in other languages, garbage collection is a great way to manage memory in the heap but finalizers are a terrible way to manage other kinds of resources. The only correct use of a finalizer is as a last-ditch effort to clean things up, for example if a programmer forgets to close a file. -- Andrew Haley Java Platform Lead Engineer Red Hat UK Ltd. <https://www.redhat.com> https://keybase.io/andrewhaley EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671