- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- C problem: Scandir memory leak
Operating System - HP-UX
1823920
Members
3088
Online
109667
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
04-05-2001 03:49 AM
04-05-2001 03:49 AM
C problem: Scandir memory leak
I have a Pro*C program which reads the files from a directory on filename order. I am using scandir for this. I copied the basic code from the scandir manpage. However, I have a memory leak which is causing the program to fail every 10 or so hours. I can see the process size getting larger over time. Here is what i have:
struct dirent **filelist, **list;
.
.
.
if ((vi_num_files = scandir(vc_data_dir, &filelist, f_filter_files, alphasort)) < 0)
{
printf(vc_log_msg, "Error performing scandir: %d ", vi_num_files);
exit(1);
}
if (vi_num_files)
{
for (vi_loop_counter = 0, list = filelist; vi_loop_counter < vi_num_files; vi_loop_counter++)
{
/* Do stuff with the file */
free(*list);
list++;
}
free (filelist)
}
The program is failing on the scandir, I assume because the malloc cannot allocate any memory dur to the leak. The directory permissions are not a problem.
Any ideas?
thanks
Alan
struct dirent **filelist, **list;
.
.
.
if ((vi_num_files = scandir(vc_data_dir, &filelist, f_filter_files, alphasort)) < 0)
{
printf(vc_log_msg, "Error performing scandir: %d ", vi_num_files);
exit(1);
}
if (vi_num_files)
{
for (vi_loop_counter = 0, list = filelist; vi_loop_counter < vi_num_files; vi_loop_counter++)
{
/* Do stuff with the file */
free(*list);
list++;
}
free (filelist)
}
The program is failing on the scandir, I assume because the malloc cannot allocate any memory dur to the leak. The directory permissions are not a problem.
Any ideas?
thanks
Alan
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2001 09:28 AM
04-05-2001 09:28 AM
Re: C problem: Scandir memory leak
Perhaps examining errno will give a clue
as to what's going wrong. The man page
for scandir() doesn't say that it sets errno,
but the underlying malloc() ought to be
setting it.
See the man pages for malloc(), perror() and
errno for details.
If you have Purify, try running it on your code.
Purify claims that HP's remove() leaks memory;
maybe scandir() leaks, too. Also try installing
the latest libc patch to see if that helps.
as to what's going wrong. The man page
for scandir() doesn't say that it sets errno,
but the underlying malloc() ought to be
setting it.
See the man pages for malloc(), perror() and
errno for details.
If you have Purify, try running it on your code.
Purify claims that HP's remove() leaks memory;
maybe scandir() leaks, too. Also try installing
the latest libc patch to see if that helps.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP