A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2000-August/008932.html below:

[Python-Dev] stack check on Unix: any suggestions?

[Python-Dev] stack check on Unix: any suggestions? [Python-Dev] stack check on Unix: any suggestions?M.-A. Lemburg mal@lemburg.com
Tue, 29 Aug 2000 22:39:18 +0200
Fredrik Lundh wrote:
> 
> ...
> 
> or maybe the optimizer removed your buffer variable?
> 
> try printing the buffer address, to see how much memory
> you're really consuming here.
> 
>      printf("%p %d\n", buffer, depth);

I got some more insight using:

int checkstack(int depth)
{
    if (depth <= 0)
	return 0;
    checkstack(depth - 1);
}

int recurse(int depth)
{
    char stack[2048];
    char *heap;
    
    memset(stack, depth % 256, sizeof(stack));
    heap = (char*) malloc(2048);

    /* Call recursively */
    printf("stack %p heap %p depth %d\n", stack, heap, depth);
    checkstack(depth);
    recurse(depth + 1);
    return 0;
}

main()
{
    recurse(0);
}

This print lines like these:
stack 0xbed4b118 heap 0x92a1cb8 depth 9356

... or in other words over 3GB of space between the stack and
the heap. No wonder I'm not seeing any core dumps.

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4