473,387 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Handling Out of memory - Linux

Hi!

I have the following question.

If a program, using the new operator, eats a lot of memory, linux kills
it before the method specified at set_new_handler gets called!

Is there a way to handle the out of memory condition in Linux? What is
the best practice?

Thanks.
Paulo
May 12 '07 #1
3 3010
On Sat, 12 May 2007 19:42:40 +0100, Paulo da Silva wrote:
>I have the following question.

If a program, using the new operator, eats a lot of memory, linux kills
it before the method specified at set_new_handler gets called!
Do you really ever run out of memory in a real application?
>Is there a way to handle the out of memory condition in Linux? What is
the best practice?
See:
http://www.linuxdevcenter.com/pub/a/...of-memory.html
--
Roland Pibinger
"The best software is simple, elegant, and full of drama" - Grady Booch
May 12 '07 #2
On May 12, 9:10 pm, rpbg...@yahoo.com (Roland Pibinger) wrote:
On Sat, 12 May 2007 19:42:40 +0100, Paulo da Silva wrote:
I have the following question.
If a program, using the new operator, eats a lot of memory, linux kills
it before the method specified at set_new_handler gets called!
Do you really ever run out of memory in a real application?
Have your really never seen a program with a memory leak:-)?

There are any number of other reasons why one might run out of
memory in a specific application, of course. Regretfully, for
the most frequent one I know, the memory you run out of is
stack, and that's undefined behavior. (I know platform specific
ways of protecting against the error, but nothing within the
language.)

--
James Kanze (Gabi Software) email: ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

May 12 '07 #3
On Sat, 12 May 2007 19:42:40 +0100, Paulo da Silva wrote:
Hi!

I have the following question.

If a program, using the new operator, eats a lot of memory, linux kills
it before the method specified at set_new_handler gets called!

Is there a way to handle the out of memory condition in Linux? What is
the best practice?
At a shell prompt do

$ cat /proc/sys/vm/overcommit_memory

If the value is not 0 you have memory overcommit enabled. This means you
can successfully request more memory than is available in terms of
virtual memory. However eventually your system can run out of memory if
more memory is actually used (i.e. written to) than is available. That
means every write access to unused memory can potentially trigger an out
of memory condition it does not even need to be your program that
triggers it.

To avoid this behaviour do

$ echo 0 >/proc/sys/vm/overcommit_memory

This will cause memory allocations to fail if not enough virtual memory
is available i.e. when you call new and not sometime later when the
memory is actually used.

--
Markus Schoder
May 12 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bouchia.nazha | last post by:
Hello I have encountered a problem using tomcat, linux and ssl. My problem seem to be a JVM memory deallocation problem on Linux. This is my configuration: OS: Redhat7.2 Tomcat: 4.0 Jdk:...
3
by: Ian | last post by:
Hi all, I have a problem. I have an application which needs to work with a lot of data, but not all at the same time. It is arranged as a set of objects, each with lots of data that is created...
6
by: hauger | last post by:
(DB2 V.8.1) Hi @ll, when i start my DB2 and my application connects and makes some SQL Tests my system is running out of memory (UNITED LINUX 1.0) goes slow and needs very very long time to...
5
by: Jeong-Gun Lee | last post by:
I'm writing a code of writing a value to a specific memory address. ================================================================= #include <stdio.h> int main() { long air; long...
3
by: Alberto Giménez | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi there! I'm doing some homework (almost finished), but now i'm reconsidering a design decission I made at the beginning. This is about error...
35
by: Alex Martelli | last post by:
Having fixed a memory leak (not the leak of a Python reference, some other stuff I wasn't properly freeing in certain cases) in a C-coded extension I maintain, I need a way to test that the leak is...
7
by: vansky | last post by:
Dear all, im porting a WIN APP to LINUX, and face some problems that r hard for me to solve, could u dear guys give me some hands? i'd like to reimplement the following funcs or replace them...
17
by: frederic.pica | last post by:
Greets, I've some troubles getting my memory freed by python, how can I force it to release the memory ? I've tried del and gc.collect() with no success. Here is a code sample, parsing an XML...
1
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.