- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- memory leak in fopen() and pthread_create?
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
тАО01-12-2004 06:26 AM
тАО01-12-2004 06:26 AM
memory leak in fopen() and pthread_create?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-12-2004 09:15 PM
тАО01-12-2004 09:15 PM
Re: memory leak in fopen() and pthread_create?
I think you don't have to worry about this.
I guess these founctions just initialize buffers needed for new file handle, or thread slot. They are allocated on demand, that is at the first time they are used and should be deallocated at the library cleanup, that is just at the end of process.
Just as a test you could try to close and reopen the file (confirm that you will get the same handle each time). If the handle is the same, but it allocates resources each time when it is returned, then you have something to worry.
I bet the allocation will be only at the first time.
Good luck
Adam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2004 06:05 AM
тАО01-13-2004 06:05 AM
Re: memory leak in fopen() and pthread_create?
Purify doesn't show any memory fragments asoociated with fopen unless I open six files simultaneously in a process that creates one detached thread. I open the files in the thread and not in the main thread. Regarding the test you suggest I run, I'm not sure what you mean?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-13-2004 11:32 PM
тАО01-13-2004 11:32 PM
Re: memory leak in fopen() and pthread_create?
What do you mean by
'open six files _simultaneously_'?
You mean one by one, but not in the main thread?
The test I was thinking of is reopening the same filehandle again. If it was already initialized, on the first open, it shouldn't be initialized again. Something like below:
FILE *first, *last;
first = fopen( /*...*/); // the buffers are initialized;
fclose( first ); // we have to free it to allow to be reused again.
for( int i = 10 ; i ; --i ) {
last = fopen( /*...*/);
if( last == first ) {
// the same handle - should be initialized already, so no new allocations expected
} else {
// different handle - everything can happen
}
fclose( last );
}
Good luck
Adam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-14-2004 02:12 AM
тАО01-14-2004 02:12 AM
Re: memory leak in fopen() and pthread_create?
Re the simultaneously open files, follows is an example of what a created thread does (not in the main thread):
f1 = fopen();
f2 = fopen();
f3 = fopen();
f4 = fopen();
f5 = fopen();
f6 = fopen();
fclose(f1);
fclose(f2);
fclose(f3);
fclose(f4);
fclose(f5);
fclose(f6);
Re the test you suggested, 'last == first' happens everytime. Would it help if I attached the output from Purify's 'memory in use at exit' report?
Many thanks for you help!
Regards, Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-14-2004 06:03 AM
тАО01-14-2004 06:03 AM
Re: memory leak in fopen() and pthread_create?
I'm not surprized that last == first.
But the thing this was about to test is - if the memory usage grows, as you do more fopen() fclose() calls? In other words - if you change the value initializing index 'i' in loop - do you have different results?
If yes - this can mean leakage.
If not - I wouldn't worry any more.
Good luck
Adam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-14-2004 06:47 AM
тАО01-14-2004 06:47 AM
Re: memory leak in fopen() and pthread_create?
Yes, heap use grows. I've confirmed this via Purify and by adding mallinfo() calls.
I'm wondering if these leaks are fixed via patches or if I've missed a compiler/linker flag?
Thanks, Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-14-2004 11:18 PM
тАО01-14-2004 11:18 PM
Re: memory leak in fopen() and pthread_create?
Well, so you have the bad news afterall.
Unluckilly I don't know how to help next.
Maybe there is some patch for it.
Hey! People with HP logo! Don't just sit there - say something.
Good luck
Adam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-15-2004 12:13 AM
тАО01-15-2004 12:13 AM