What can cause kernel out_of_memory error?

120

Solution 1

Check the log messages for indications of the kernel out-of-memory killer, or OOM killed in the output of dmesg. That may give some indication of which process(es) were the target of the OOM killer. Also take a look at the following:

http://lwn.net/Articles/317814/

and

http://linux-mm.org/OOM_Killer

What does this system do? Are you exhausting swap at the same time? It looks like rsyslogd is the issue, based on your external link detailing the crash. This could be a situation where a periodic restart of the app would be handy.

Solution 2

2.6.18 is a very old kernel. I've run into problems where certain conditions can trigger infinite loops in the kernel, resulting in anything from memory exhaustion to I/O bandwidth being entirely used up flushing the same data to disk in an endless loop (which causes load spikes but normal CPU use.)

These bugs tend to get fixed soon after being reported, so a kernel upgrade is an easy fix for this - plus upgrading the kernel means you get some security fixes thrown in for free :-)

Solution 3

On another note, don't forget that Cacti and the like graph at a certain resolution ( collectd is 5s by default, cacti I believe 30s by default ) so you have a period of 30-60 seconds that do not necessarily show up on your graphs ... if the system is totally bogged down, this will also affect the data collection daemon.

You may find additional useful information within your log files be they general /var/log/messages or service specific /var/log/apache2/error.log.

If you cannot, then I'd recommend you go over your services ( I noticed apache2 within your log extract above ) and verify whether they are capable of causing a memory exhaustion situation on your server. ( ex.: default apache configuration, with mod_prefork and php should be capable of bringing your system to a halt ).

Share:
120

Related videos on Youtube

georgeous
Author by

georgeous

Updated on September 17, 2022

Comments

  • georgeous
    georgeous almost 2 years

    I'm brand new to XNA games development and am currently practising to make games.

    I started by creating a simple platformer, and slowly built up the logic of the game and game features. My most recent addition seems to have broken the project. It started after adding a health bar function, where I add 11 textures (health bar empty, health bar 1/10, health bar 2/10 etc...).

    When the player encounters a harmful object such as a spike in the game, the texture displayed for the health bar change (so if health bar was on 9, the texture would change to healthBar8).

    The issue started off as an actual error preventing the project to build which was caused by having two of the same project open in two different Visual Studio windows. (This was so stupid of me and I googled how to fix the given error before finding out that I had two windows open). The suggested fix was to enter these two lines in the pre-build command line box:

    if exist "$(TargetPath).locked" del "$(TargetPath).locked" if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"

    This seemed to have fixed the error but now my project only builds and doesn't launch, so I closed the extra window I discovered I had open and removed the two lines from the pre-build command line box, but now the project just builds and doesn't launch.

    I tried creating a new project, and checked to see if it built (it did, so Visual Studio itself is not the problem) then copied and pasted the broken project's code into this new project, which still didn't launch.

    I have no idea what is causing this and it's extremely annoying. I'm really sorry if my question is stated poorly as this is my first Stack overflow question (because I have never felt the need to actually post question on the internet), but I can't find a solution after extensive googling.

    public class MainGame : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        SpriteFont coinCount;
    
        List<PlatformSprite> platformsList;
        List<Consumable> pickUpList;
        List<StaticEnemy> staticEnemyList;
    
        //public Texture2D currentHealthTexture;
        //Texture2D healthEmpty;
        //Texture2D health1;
        //Texture2D health2;
        //Texture2D health3;
        //Texture2D health4;
        //Texture2D health5;
        //Texture2D health6;
        //Texture2D health7;
        //Texture2D health8;
        //Texture2D health9;
        //Texture2D healthFull;
    
        //List<Texture2D> healthBarsList;
    
        Texture2D coinAnim;
        Texture2D coinAnimBig;
        Texture2D floatingPlatform;
        Texture2D groundPlatform;
        Texture2D redPlayer;
        Texture2D spikeEnemy;
    
        Rectangle destRect;
        Rectangle sourceRect;
        Rectangle destRectSmall;
        Rectangle sourceRectSmall;
    
        PlayerSprite player;
        KeyboardState keyboardState;
    
        float elapsed;
        float delay = 90f;
        int frameCount = 0;
    
        public const int screenHeight = 550;
        public const int screenWidth = 800;
    
        public MainGame()
        {
            graphics = new GraphicsDeviceManager(this);
    
            graphics.PreferredBackBufferHeight = screenHeight;
            graphics.PreferredBackBufferWidth = screenWidth;
    
            Content.RootDirectory = "Content";
        }
    
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            destRect = new Rectangle(100, 100, 60, 60);
            destRectSmall = new Rectangle(100, 300, 20, 20);
            base.Initialize();
        }
    
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
    
            coinCount = Content.Load<SpriteFont>("CoinCount");
    
            platformsList = new List<PlatformSprite>();
            pickUpList = new List<Consumable>();
            //healthBarsList = new List<Texture2D>();
            staticEnemyList = new List<StaticEnemy>();
    
            coinAnim = Content.Load<Texture2D>("CoinSpinAnim");
            coinAnimBig = Content.Load<Texture2D>("CoinAnim");
            floatingPlatform = Content.Load<Texture2D>("Platform1");
            groundPlatform = Content.Load<Texture2D>("GroundPlatform1");
            redPlayer = Content.Load<Texture2D>("TestSprite");
            spikeEnemy = Content.Load<Texture2D>("Spike");
    
            //healthEmpty = Content.Load<Texture2D>("HealthBarEmpty");
            //health1 = Content.Load<Texture2D>("HealthBar1");
            //health2 = Content.Load<Texture2D>("HealthBar2");
            //health3 = Content.Load<Texture2D>("HealthBar3");
            //health4 = Content.Load<Texture2D>("HealthBar4");
            //health5 = Content.Load<Texture2D>("HealthBar5");
            //health6 = Content.Load<Texture2D>("HealthBar6");
            //health7 = Content.Load<Texture2D>("HealthBar7");
            //health8 = Content.Load<Texture2D>("HealthBar8");
            //health9 = Content.Load<Texture2D>("HealthBar9");
            //healthFull = Content.Load<Texture2D>("HealthBarFull");
            //healthBarsList.Add(healthEmpty);
            //healthBarsList.Add(health1);
            //healthBarsList.Add(health2);
            //healthBarsList.Add(health3);
            //healthBarsList.Add(health4);
            //healthBarsList.Add(health5);
            //healthBarsList.Add(health6);
            //healthBarsList.Add(health7);
            //healthBarsList.Add(health8);
            //healthBarsList.Add(health9);
            //healthBarsList.Add(healthFull);
    
            platformsList.Add(new PlatformSprite(groundPlatform, new Vector2(0, 454)));
            platformsList.Add(new PlatformSprite(floatingPlatform, new Vector2(500, 330)));
            platformsList.Add(new PlatformSprite(floatingPlatform, new Vector2(100, 290)));
            platformsList.Add(new PlatformSprite(floatingPlatform, new Vector2(300, 250)));
            platformsList.Add(new PlatformSprite(floatingPlatform, new Vector2(170, 250)));
            platformsList.Add(new PlatformSprite(floatingPlatform, new Vector2(350, 360)));
    
            staticEnemyList.Add(new StaticEnemy(spikeEnemy, platformsList[0], 300));
    
            pickUpList.Add(new Consumable(coinAnim, platformsList[1], 30, sourceRectSmall));
            pickUpList.Add(new Consumable(coinAnim, platformsList[3], 45, sourceRectSmall));
            pickUpList.Add(new Consumable(coinAnim, platformsList[4], 60, sourceRectSmall));
    
            player = new PlayerSprite(redPlayer, platformsList, pickUpList, staticEnemyList, 0);
        }
    
        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }
    
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
    
            keyboardState = Keyboard.GetState();
    
            //currentHealthTexture = healthBarsList[player.playerHealth];
    
            player.Update(keyboardState);
    
            elapsed += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
    
            if (elapsed >= delay)
            {
                if (frameCount >= 5)
                {
                    frameCount = 0;
                }
                else
                {
                    frameCount++;
                }
    
                elapsed = 0;
            }
    
            sourceRect = new Rectangle(60 * frameCount, 0, 60, 60);
            sourceRectSmall = new Rectangle(20 * frameCount, 0, 20, 20);
    
            foreach (Consumable c in pickUpList)
            {
                c.Update();
            }
    
            base.Update(gameTime);
        }
    
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
    
            spriteBatch.Begin();
    
            foreach (PlatformSprite p in platformsList)
            {
                p.Draw(spriteBatch);
            }
    
            foreach (Consumable c in pickUpList)
            {
                c.Draw(spriteBatch, sourceRectSmall);
            }
    
            foreach (StaticEnemy se in staticEnemyList)
            {
                se.Draw(spriteBatch);
            }
    
            //spriteBatch.Draw(currentHealthTexture, new Vector2(680, 10), Color.White);
    
            spriteBatch.DrawString(coinCount, ":  " + player.playerCoinCount, new Vector2(30, 10), Color.White);
            spriteBatch.Draw(coinAnim, new Rectangle(10, 10, 20, 20), new Rectangle(0, 0, 20, 20), Color.White);
    
    
            player.Draw(spriteBatch);
    
            spriteBatch.End();
    
            base.Draw(gameTime);
        }
    }
    

    As you can see I've commented out all of the health bar code, I hope this adds detail to my question but really sorry if this is a terrible question I just have no clue what to do or where to start to fix it.

    TEMPORARY UPDATE - FIXED IT!! :D

    I narrowed it down to one single while loop that caused this 'build but not launch' error. I tried a few times commenting the loop out and then bringing it back on the table again and every time I commented it out it launched the game successfully. I'm on my phone right know so I apologise for not quoting the exact loop yet but it was a while loop, something like: int j :0; while (j < staticEnemyList.Count) { if(player.enclosedRectangle.Intersects (staticEnemyList[i].GetRectangle)) { playerHealth-- } else { j++ } }

    I think it has something to do with setting the enemy list index as 'i' instead of j but this didn't return an error as I had a loop before this base on an integer called 'i'. Still have no clue as to why this while loop broke visual studio, any suggestions would be cool? Again I am so sorry for my terrible format etc as soon as I get on my computer I will update with the actual while loop code. Thanks everyone who commented, great advice - AGAIN... sorry - really difficult to comment on phone and I can't answer within 8 hours, this is only temporary :)

    • Aleksandr Levchuk
      Aleksandr Levchuk over 13 years
      Please post the entire /var/log/messages or the output of grep -C 5 oom-killer /var/log/messages.
    • georgeous
      georgeous over 10 years
      Uh oh how do yoy format
    • Cemafor
      Cemafor over 10 years
      Have you tried turning it off and on again?
    • georgeous
      georgeous over 10 years
      Might as well try it, nothing else is working.
    • Magus
      Magus over 10 years
      There's way too much going on in your main game loop. Also, I'd look into MonoGame, which is still supported - unlike XNA.
    • itsme86
      itsme86 over 10 years
      As an aside, since you're still learning, can I suggest putting all of the healthbar images in a single texture file and just drawing the correct one using different sourcerects?
    • georgeous
      georgeous over 10 years
      You mean where I've set the screen dimensions or another loop? but yes I shall do that thanks, and oh okay, yeah that makes a lot more sense, although this won't fix the 'Not launching' bug. But thanks for the tips :D
    • Magus
      Magus over 10 years
      @CompleteNoob: Everything in Update and Draw is part of the main game loop. Almost all of what is currently in there should be delegated to different classes as soon as possible. You really don't want to deal with the resulting mess otherwise. A simple improvement may be to place all your objects with Draw methods into either Components (requiring .OfType<IDrawable>) or perhaps a List<IDrawable> so you only need one loop for them all. The main game loop has very few roles it should be filling. Don't let it do too much.
    • georgeous
      georgeous over 10 years
      but surely in the end the system is carrying out all the same amount of code as before if not more? sorry I know you're right it's just I don't know the architecture at all I'm just coding until things work at the moment, trying to learn what does what before I start organising my code, I appreciate the tips a lot, need all the advice I can get
    • georgeous
      georgeous over 10 years
      @itsme86 Oh yeah so I put all the health bars into on sprite sheet, works perfectly, feels much neater, and I feel a lot smarter :D thanks a lot
    • Magus
      Magus over 10 years
      You should write an answer to your own question now, rather than edit the question. But yeah, moving things out of that class may indeed result in more code. That's fine, because it keeps your concerns separated. No class should know more than it absolutely has to. That way, when one thing changes, nothing else has to.
  • tmow
    tmow over 13 years
    Seems to be a known rsyslogd bug never solved (read the last post). bugs.debian.org/cgi-bin/bugreport.cgi?bug=509292 I'd advise to report it again.
  • janneb
    janneb over 13 years
    He's using the RHEL5 kernel which has a lot of patches on top of vanilla 2.6.18, and gets security updates from the vendor. That being said, 2.6.18-164.9.1 is old and has several more or less serious vulnerabilities (newest EL5 kernel ATM being 2.6.18-194.26.1).
  • jonathanserafini
    jonathanserafini over 13 years
    If passenger is causing you to run out of memory you may have an problem as I don't believe there's a way to limit it directly from within passenger. One thing you may want to look at is limiting memory usage through Cgroups via the cgroup-bin package. But this will most certainly require a kernel update on your part.