LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-21-2015, 11:30 PM   #1
dayalan_cse
Member
 
Registered: Oct 2006
Posts: 132

Rep: Reputation: 15
libstdc++.so.6.0.13: failed to map segment from shared object: Cannot allocate memory


Hello All,

In Linux 32-bit mode, when i run a application, I see the below error.

Please note: this is not specific to any application as it is related to loading sharedobject from .so file to RAM or virtual memory swap in content from disk to RAM.

Error:
----------
libstdc++.so.6: failed to map segment from shared object: Cannot allocate memory

Does anybody have run in to this error? I looked for information in net, I found that we can use /usr/local/bin/softlimit but i dont find this command in my Linux installation.

Does anybody run in to this error and resolved it? please share some information.
 
Old 01-22-2015, 01:04 AM   #2
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,727

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
check this thread, was possible the same problem
http://www.linuxquestions.org/questi...object-801827/
 
Old 01-22-2015, 02:58 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Code:
strace <executable>
might show something (not for beginners, though)
 
Old 01-28-2015, 10:20 PM   #4
dayalan_cse
Member
 
Registered: Oct 2006
Posts: 132

Original Poster
Rep: Reputation: 15
libstdc++.so.6.0.13: failed to map segment from shared object: Cannot allocate memory

Quote:
Originally Posted by NevemTeve View Post
Code:
strace <executable>
might show something (not for beginners, though)
I tried, strace, mmap2 failed with ENOMEM return code.

mmap2(NULL, 955544, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 12, 0) = -1 ENOMEM (Cannot allocate memory)

955544 is this bytes? or Kb? or Mb? I guess it should be bytes which comes around 933 Kb.

Does it mean the system does not have enough virtual memory or its user limit set for individual user id?

I did use, limit to identify what are the resource limits.

cputime unlimited
filesize unlimited
datasize unlimited
stacksize unlimited
coredumpsize unlimited
memoryuse unlimited
vmemoryuse unlimited
descriptors 1024
memorylocked 32 kbytes
maxproc 192801


vmemoryuse is nothing but, virtual memory is 'unlimited', so it is not clear why mmap2 is unable to allocate memory?

Please note, the same application if i run with 64-bit binaries, I dont see this 'mmap2 ENOMEM' error.
 
Old 01-29-2015, 01:06 AM   #5
a4z
Senior Member
 
Registered: Feb 2009
Posts: 1,727

Rep: Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742Reputation: 742
unlimited on 32 bit is not unlimited, its a lower limit than the 'unlimited' on 64 bit
and the address space for a single process is more limited on 32 bit, (~4 GB) than on 64 bit (~ very much)
this might explain why you run out of memory on 32 bit but not in 64 bit.

you can try to use MAP_SHARED instead of private since private uses much more memory

Quote:
MAP_SHARED Share this mapping. Updates to the mapping are visible to
other processes that map this file, and are carried through
to the underlying file. The file may not actually be
updated until msync(2) or munmap() is called.

MAP_PRIVATE
Create a private copy-on-write mapping. Updates to the map-
ping are not visible to other processes mapping the same
file, and are not carried through to the underlying file.
It is unspecified whether changes made to the file after the
mmap() call are visible in the mapped region.
MAP_DENYWRITE is unused


not also
Quote:
ENOMEM No memory is available, or the process’s maximum number of map-
pings would have been exceeded.
do you map more than one file?
 
Old 01-29-2015, 07:56 AM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Indeed ... if you map the area "private," this specifies "copy-on-write (COW)" semantics, in which you receive a private copy of each shared page if you touch them. This comes out of your private virtual memory allocation. This combination of options, therefore, seems strange and wasteful to me.
 
  


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
error while loading shared libraries: libstdc++.so.6: cannot open shared object file: mahiba Linux - Hardware 2 05-10-2013 05:18 PM
error while loading shared libraries: libstdc++.so.6: cannot open shared object file: vswapnasr@gmail.com Linux - Software 1 05-04-2013 06:49 AM
error while loading shared libraries: libstdc++.so.5: cannot open shared object file: Franziss Linux - Newbie 10 06-28-2010 05:47 AM
[SOLVED] yum failed to map segment from shared object robmoser Red Hat 4 04-19-2010 12:22 PM
error while loading shared libraries: libstdc++.so.5: cannot open shared object file PaulyWally Debian 2 10-18-2008 05:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:48 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