- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: cobol memory leak when using threads
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2007 01:54 AM
тАО08-06-2007 01:54 AM
cobol memory leak when using threads
Hi gurus:
I am trying to find where is the error in this code. I just want to create a thread and from the main program, kill it.
I do dat in a loop and the m├йmory grows and grows. I can se than the tread is beeng killed but i don┬┤t know why the memory is growing.
Could you pleas help me ?
Thanks in advance:
The code :
$set sourceformat"free"
$set REENTRANT"1"
IDENTIFICATION DIVISION.
PROGRAM-ID. prueba_signal.
AUTHOR. Ignacio Javier Sanchez.
DATE-WRITTEN. 06-06-2007.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 flag pic s9(9) comp-5.
01 id-hilo-unix pic s9(9) comp-5 value 0.
01 unix-self pic s9(9) comp-5 value 0.
01 thread-id-p-mixto usage pointer.
LINKAGE SECTION.
PROCEDURE DIVISION.
perform until 1=2
call 'CBL_THREAD_CREATE' using 'HILO-PRUEBA'
0
by value 0
0
0
0
by reference thread-id-p-mixto
call "usleep" using by value 500000
display "hilo nuevo creado.........................."
perform mata-hilo
end-perform
stop run.
mata-hilo.
display "Vamos a hacer un kill sobre el hilo"
call 'CBL_THREAD_KILL' using by value thread-id-p-mixto
.
fin-mata-hilo.
entry "HILO-PRUEBA".
display "soy el hilo hijo"
call "sleep" using by value 300
stop run
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2007 01:59 AM
тАО08-06-2007 01:59 AM
Re: cobol memory leak when using threads
It may not be your code.
It may be a problem with the cobol compiler.
It could also be a system problem. Has the system been patched with a recent bi-annual patch set?
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2007 10:17 PM
тАО08-06-2007 10:17 PM
Re: cobol memory leak when using threads
Is there a way to get the status of your CBL_THREAD_KILL?
If the solution still isn't obvious, you'll have to debug at the C level and use gdb's leak detection and perhaps use tusc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2007 11:22 PM
тАО08-06-2007 11:22 PM
Re: cobol memory leak when using threads
Thanks:
The result of the call 'CBL_THREAD_KILL' is a success. I can see than the thread is not present and so the System shows it.
But the memory grows.....
The stop run is there because i was doing tests. I think it makes no difference in the code.
If i do not kill de thread, it finishes by it self, there is no memory leak.
I have made a work around using a signal that the thread captures and then executes a stop run.
Could you please tell me how can I debug this proces with gdb ? I thought that debugger was for C only.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-06-2007 11:51 PM
тАО08-06-2007 11:51 PM
Re: cobol memory leak when using threads
I thought it would stop the whole process. That's what it did in COBOLII/iX.
>If i do not kill the thread, it finishes by it self, there is no memory leak.
Have you created the thread in the right state? If you use don't use detach, you may have to use pthread_join to recover the space?? PTHREAD_CREATE_JOINABLE is the default
>Could you please tell me how can I debug this proces with gdb? I thought that debugger was for C only.
You are imagining you have a COBOL program. You debug in assembly mode. ;-)
You just use:
gdb executable
(gdb) set heap-check on
(gdb) r parms to your program ...
And the end:
(gdb) info leaks
You can download gdb from:
http://www.hp.com/go/wdb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2007 01:34 AM
тАО08-07-2007 01:34 AM
Re: cobol memory leak when using threads
As I recall, a "STOP RUN" in a COBOL program means immediate termination of everything. There is no cleanup (epilog) code executed.
From that standpoint, I think I would expect any thread or process that had malloc()ed memory to be killed without an opportunity to free() that memory.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2007 10:51 AM
тАО08-07-2007 10:51 AM
Re: cobol memory leak when using threads
Except if you terminate the process, the OS frees everything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-07-2007 07:21 PM
тАО08-07-2007 07:21 PM
Re: cobol memory leak when using threads
Hi:
The code is never reaching the point the "stop run." is.
The thread it is waiting 300 seconds and the main process, kills it before it gets to that point.
I i do the following:
entry "HILO-PRUEBA".
display "soy el hilo hijo"
stop run
.
What finishes is the thread and not the hole process. And all the resources ( what it was worth when the thread was created ) are free.
So, the problem begins when you want to finish a thread with the 'CBL_THREAD_KILL' call.
Regards