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 6224137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:37:09+00:00 2026-05-24T08:37:09+00:00

I am writing an algorithm to perform some external memory computations, i.e. where your

  • 0

I am writing an algorithm to perform some external memory computations, i.e. where your input data does not fit into main memory and you have to consider the I/O complexity.

Since for my tests I do not always want to use real inputs I want to limit the amount of memory available to my process. What I have found is, that I can set the mem kernel parameter to limit the physically used memory of all processes (is that correct?)

Is there a way to do the same, but with a per process limit. I have seen ulimit, but it only limits the virtual memory per process. Any ideas (maybe I can even set it programmatically from within my C++ code)?

  • 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-24T08:37:11+00:00Added an answer on May 24, 2026 at 8:37 am

    You can try with ‘cgroups’.
    To use them type the following commands, as root.

    # mkdir /dev/cgroups
    # mount -t cgroup -omemory memory /dev/cgroups
    # mkdir /dev/cgroups/test
    # echo 10000000 > /dev/cgroups/test/memory.limit_in_bytes
    # echo 12000000 > /dev/cgroups/test/memory.memsw.limit_in_bytes
    # echo <PID> > /dev/cgroups/test/tasks
    

    Where is the PID of the process you want to add to the cgroup. Note that the limit applies to the sum of all the processes assigned to this cgroup.

    From this moment on, the processes are limited to 10MB of physical memory and 12MB of pysical+swap.

    There are other tunable parameters in that directory, but the exact list will depend on the kernel version you are using.

    You can even make hierarchies of limits, just creating subdirectories.

    The cgroup is inherited when you fork/exec, so if you add the shell from where your program is launched to a cgroup it will be assigned automatically.

    Note that you can mount the cgroups in any directory you want, not just /dev/cgroups.

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

Sidebar

Related Questions

I'm having some trouble writing a correct algorithm for centering a background image. Here's
while writing an algorithm dealing with excel data if we want to compare each
I'm writing a genetic algorithm that tries to chooses a set of the data
I need to create an algorithm to layout some hierarchical data but have never
I'm not looking to copy a qsort algorithm. I'm practicing writing qsort and this
I'm writing an algorithm in OpenCL which needs a data structure temporarily (during execution)
I am writing an algorithm to find the dominating set of a tournament graph.
I'm writing an algorithm in PHP to solve a given Sudoku puzzle. I've set
I'm writing an algorithm that iterates over a list of points, calculates the distance
I'm writing a search algorithm in C++, and one of the things I need

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.