Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate memory with cg-mem #5

Closed
dmeneses opened this issue Sep 2, 2015 · 4 comments
Closed

Calculate memory with cg-mem #5

dmeneses opened this issue Sep 2, 2015 · 4 comments

Comments

@dmeneses
Copy link

dmeneses commented Sep 2, 2015

I want to calculate the memory usage of my program and reproduce the a memory limit exceeded. No luck so far.

To run isolate I'm using this:

./isolate --cg -i $SANDBOX_INPUT --cg-mem=$SANDBOX_MEMORY --cg-timing -t $SANDBOX_TIME -M run-stats --run ./main

I've always get time limit but not memory limit.

To reproduce the memory limit I'm using this:

int main() {
    while(true) new int;
}
@gollux
Copy link
Member

gollux commented Sep 2, 2015 via email

@bblackham
Copy link
Contributor

The reason for this is because the pointer is never dereferenced. The
new operation will be returning NULL when the memory limit is hit, but
nothing in the program uses the return value.

Out of memory errors are difficult to identify, because typically the
program just segfaults when it tries to dereference a NULL pointer from
malloc() or new.

@bblackham
Copy link
Contributor

Additionally, there is no "out of memory" result from isolate, for pretty much this reason.

However, you should be able to see when the process terminates that the cg memory is equal to the limit, which is a pretty good indication that it ran out of memory. In at least one contest system I know of, it uses the fact that the memory usage maxed out and that the program died on a SIGSEGV to assume that it is an out of memory error. It's just a guess, but a reasonable one.

dmeneses : given this, are you happy to close the issue?

@dmeneses
Copy link
Author

Yeap, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants