Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6084143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:29:12+00:00 2026-05-23T11:29:12+00:00

(forgive my poor English, I am not native) I tried Python resource module to

  • 0

(forgive my poor English, I am not native)

I tried Python resource module to limit child process.

It seems that setting RLIMIT_CPU can successfully limit the amount of cputime, but others like RLIMIT_RSS didn’t work at all.

For example, I use following script to call child.py, and set RSS limit to (1024, 1024):

import os
import sys
import resource
import subprocess

def setlimits():
    resource.setrlimit(resource.RLIMIT_RSS, (1024, 1024))

p = subprocess.Popen(["./child.py"], preexec_fn=setlimits)
print(p.wait())

child.py:

#!/usr/bin/env python3
import resource

print("RSS limit: ", resource.getrlimit(resource.RLIMIT_RSS))
a=[]
while True:
    a.append(1) # deadloop, until eat up memory

Child process print “RSS limit: (1024, 1024)” and then continue to run until killed.
I can see child.py eating my memory but RLIMIT_RSS didn’t work.

My OS is latest Archlinux (2.6.39 kernel), and Python is ver3.2.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:29:13+00:00Added an answer on May 23, 2026 at 11:29 am

    According to the documentation for setrlimit(), RLIMIT_RSS has no effect in Linux 2.4.30 and later. Also, it only counts memory marked with madvise():

    RLIMIT_RSS
    Specifies the limit (in pages) of the process’s resident set (the number
    of virtual pages resident in RAM).
    This limit only has effect in Linux
    2.4.x, x < 30, and there only affects calls to madvise() specifying
    MADV_WILLNEED.

    So, if you really want to limit processes this way, you’ll have to run a 2.4 kernel and hack the Python interpreter so it calls madvise() on allocated memory, which will probably have unexpected side-effects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(forgive my poor English) I'm writing setup.py for my Python app. My app needs
Please forgive my poor English, My Problem is that i have a article.php?id=xxx ,
This is my first post, and first please forgive me for my poor english.
please forgive me for my poor english and my big ignorance on programming. I'm
Forgive me if this is a repeat question. I've searched StackOverflow and did not
Please forgive my ignorance and poor SQL programming skills but I am normally a
I'm not too great with xdebug so forgive me if this is a stupid
Forgive me if this is a dupe but I couldn't find anything that hit
Forgive the title, I'm not really sure how to explain what I'm seeing. Sample
Forgive me if this post is too naive-sounding. I have a Twitter app that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.