![]() |
|
|
#1 |
|
Gast/Guest
Beiträge: n/a
|
Hi
Is it possible that releasing memory objects created with clCreateBuffer() or clCreateImage2D() by using the method clReleaseMemobject() doesn't suffice? Each time I get rid of every object I don't need in the future but still the memory remains in use or something? Are there some other things in openCL that I have to clear as well. I tried debugging my code line per line and monitoring the memory usage of the gpu when clReleaseMemobject() is called. But if i have for example 40 MB in use the drops down to like 38 MB. Running my code once is fine but when test running for 15 or more testcases with larger and larger images the memory gets completely full and crashes with a memory allocation failure. I hope someone knows how memory can be freed up. Thanks in advance! |
|
|
|
#2 |
|
Super-Moderator
Registriert seit: 05.08.2008
Beiträge: 1.418
|
Hello
You basically have to release everything that you create. When you don't need them any more, you have to release memory objects, events, command queues... and finally, the context. I just ran another test Java Code:
(on Win7/64) and did not encounter any problem. How are you measuring the memory usage? Can you post an example where the problem occurs? bye Marco |
|
|
|
|
|
#3 |
|
Gast/Guest
Beiträge: n/a
|
Hi
The program consists of a number of operations that will be applied to images i provide. Because of performance issues it's commonly known to reduce the amount of times you read and write from and to memory. Because of that i keep the image and memory objects where they are, so i can use the output from 1 operation as the input of another operation. I figured that if i can reuse memory objects like that it should also be possible to keep working with the same context and commandqueue, that is why i made a custom java class called OpenCLPlatform.java where i instantiate all the different parts of openCL such as the context, the commandqueue, contextproperties, platforms, devices, etc. Because I will use the same images over and over again and i only want to copy them once into memory i use a class named OpenCLImage which holds some info about the images and a memory object so i can reuse the same memory again in other operations The operations that can be applied on images all have a kernel and a program that i want to create only once because i will be using the same kernel over and over again. I did this by giving the operation classes a static{} part where i make the program and the kernel. I will provide you the code of the OpenCLPlatform and OpenCLImage, one of the many operations (they all look a lot alike) and a part of the code where i use these operations on images and where i release their memory when i no longer need it. OpenCLPlatform: Java Code:
OpenCLImage: Java Code:
an Operation: Java Code:
example usage code: Java Code:
Beware of the many commented lines, it's an experimental process for me as i'm pretty new to openCL (you can tell by my previous beginner questions). I hope i provided enough details. Again, thanks in advance! |
|
|
|
#4 |
|
Super-Moderator
Registriert seit: 05.08.2008
Beiträge: 1.418
|
Hi
Of course, the context, command queue and kernels should be created only once, so everything should be fine here. I tried another simple test like that Java Code:
But of course, I have commented out the kernel. As far as I can see, the only really "variable" CL objects (which may be created and deleted) are the cl_mems inside the OpenCLImage. So this might be the source of the problem. However, when you are always calling "destroy" on the images, this should be OK. Can you describe in more detail under which condition you receive a memory allocation failure? Note that there is a maximum size for memory allocations (this is a device property that can be queried using CL_DEVICE_MAX_MEM_ALLOC_SIZE). Maybe the images are just too large? bye Marco |
|
|
|
|
|
#5 |
|
Gast/Guest
Beiträge: n/a
|
I think I can be almost sure that the image isn't too large for the gpu to handle, because when I run only that image it doesn't throw an exception like when I run all the images in a row. The program also always gets stuck at the same piece in the code.
Process explorer to track the memory usage of the gpu, and i can clearly tell that it just keeps getting filled without the memory being released. And in the end, when it's almost completely full and he tries to allocate another memobject for an image operation it crashes. ... While writing this post it seems that I made a mistake in overwriting an OpenCLImage object.. By overwriting the cl_mem object it gets the new value but the old one still remains.. Thanks for giving me some additional insight in memory allocation etc. I appreciate the help ![]() |
|
|
|
#6 |
|
Super-Moderator
Registriert seit: 05.08.2008
Beiträge: 1.418
|
|
|
|
|
|
|
#7 |
|
Gast/Guest
Beiträge: n/a
|
One of the simpler operations I did was a contraststretch where I took an OpenCLImage input object, and returned an OpenCLImage output object.
The problem was situated in these lines of code: Java Code:
This was solved by doing: Java Code:
Giving the java object cl_mem a new value does not get rid of the old value of a cl_mem object. Therefore I make a new one and dispose of the old one. My memory allocation got previously filled with more than a gig of memory whilst now it doesnt go over 50 MB. ![]() Problem solved in my eyes and an important lesson learned. |
|
|
| Lesezeichen |
| Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1) | |
| Themen-Optionen | Thema durchsuchen |
|
|
Ähnliche Themen
|
||||
| Thema | Autor | Forum | Antworten | Letzter Beitrag |
| Memory Leak in FlapDockStation? | Q_LeSoc | DockingFrames | 1 | 21.02.2012 08:45 |
| Memory leak in JOCLSimpleConvolution? | culturedyogurt(John) | JOCL | 7 | 01.02.2012 19:32 |
| Memory Leak With Eclipse Theme | dallimor | Bugs | 8 | 22.11.2011 11:45 |
| Problem with clEnqueueNDRangeKernel, memory leak | Roman | JOCL | 2 | 18.03.2011 06:23 |
| Memory Leak with Action Guards? | Unregistered | DockingFrames | 4 | 27.07.2009 08:33 |