LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-08-2012, 06:00 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442

Rep: Reputation: 76
malloc: cannot allocate memory (when running a small cli program).


I have a little program to play audio CDs (CDDA or Red Book). Once in a while the program debuts by giving 'Segmentation fault'. Today, invoking in such a way as to play a CD I had in the drive, it gave this message. Then I ran it with only option -h (give help and exit). No problem here. I ran it a third time thus

lazy -d

This makes the program, lazy, to just play the CD through, but -d instructs lazy to pick up the audio signal from the drive IDE bus instead of from the optical drive analog output (they used to have one). The result was:

Code:
$ lazy -d
malloc: cannot allocate memory
$
I normaly invoke 'lazy -d -f /dev/hdd -o <some_track_number>, where -f admits a device name to look for the media, and have no trouble, except, as told, in the few instances where I get segmentation fault.
But this time I have that new diagnostic element: the malloc message. Can this help to determine the cause of the segmentation fault. I have the sources of lazy.

EDIT: at the time of these runs of the program, X was running too and five instances of the web browser. Plus the memory installed in my machine is only 256MB (but this satisfies Volkerdi's requirements).OK. Then I exited X and rerun lazy, only to get the malloc message again. Does not X return the memory to the system pool when exiting?

Kernel 2.6.21.5, slackware 12.0

Last edited by stf92; 11-08-2012 at 06:12 PM.
 
Old 11-09-2012, 03:24 AM   #2
pgpython
Member
 
Registered: Dec 2005
Location: Sheffield, UK
Distribution: Gentoo
Posts: 142

Rep: Reputation: 32
When a process exits the OS should reclaim it resources it has used. For this reason I don't think the problem is X espically if you have killed of X. I would run top to see an overview of system processes and that you can get a idea of which if any processes or causing the issue. Having said that 256M is a little on the small side. In order to get it run properly you may need to get more ram or do some slimming on what processes are booted up at run time
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] malloc fails to allocate memory urrohit Programming 9 05-10-2011 12:01 AM
Allocate memory to a program before execution codegenie Programming 9 01-27-2011 11:53 AM
[SOLVED] C program. error: *** glibc detected *** ./proyecto: malloc(): memory corruption Carlos2313 Programming 4 10-24-2010 04:56 PM
How Linux allocates memory for malloc in a program johnarg Linux - Newbie 2 06-25-2006 07:15 PM
how to use malloc() to allocate the following struct? simon_qwl Programming 9 06-30-2005 11:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration