Macaulay2 / Macaulay2/M2

opportunistic memory allocation

Open
#2,029 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Interpreter
Dominant language
Macaulay2
Stars
435
Forks
297
Avg merge
4d 20h
Merged PRs (30d)
11

Description

It's hard to detect when we run out of memory!

See https://stackoverflow.com/questions/11779042/sigkill-while-allocating-memory-in-c
for an explanation of "opportunistic memory allocation" and how to disable it under Linux
with ` echo 2 > /proc/sys/vm/overcommit_memory `

The experiment below shows that with opportunistic memory allocation, the process
just gets killed with signal 9 (SIGKILL) when it runs out of memory, both
under Linux (64 bit) and under Mac OS X (64 bit). But under Debian (32 bit),
memory allocation is not opportunistic by default, and a null pointer is returned when
memory is exhausted.

Notice that when a process gets killed, there is no explanation for the user about why it got killed.
What we want to achieve is to give an error message : "out of memory".

```c
// run with gcc foo.c -o foo && ( ./foo ; echo $? )

#include
#include
#include
int main () {
int n = 0;
while (1) {
size_t size = 100000000L;
char *p = (char *)malloc(size);
// char *p = new char[size];
/* char *p = (char *)sbrk(size); */
n++;
printf("%4d: %p\n",n,p);
if (0 == p) exit(2);
if (-1 == p) exit(3);
memset(p,0,size);
}
return 0;
}
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository files or tests; begin by reproducing the provided foo.c experiment with gcc on the stated Linux and macOS environments, then locate the project's memory-allocation entry point. Done means allocation exhaustion produces an "out of memory" error rather than an unexplained SIGKILL.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux, macos
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.