Skip to main content

[Migrated content. Thread originally posted on 11 October 2011]

Using Net Express 5.1/Windows XP Pro SP3.

I have a program in which I'm dynamically allocating memory to contain a variable length table.

Calling "CBL-ALLOC_MEM" works fine - I am able to populate the table and display its contents, as required.

When I try to 'free' the memory I get a "252 Memory corruption detected (addr=xxxxxxx type 30/4)".

The program stops - as shown in Animator - on the 'call "CBL_FREE_MEM"' line as shown:

call "CBL_FREE_MEM" *> crashes on this line - memory corrupted
using by value memory-pointer
returning status-code
if not status-code = 0
move "Failed to release memory" to message-line
perform display-message
stop run
end-if.

The program doesn't even reach the 'if not status-code = 0' line.

I've set up a cobopt.cfg file containing 'set memory_strategy=0x40000000' but this has no effect.

Not sure how to proceed from here. I don't want to set up a 'static' table in Working Storage since that would be a complete waste of space for a function that will probably be only used once on each running of the program. Any clues appreciated.

TIA

[Migrated content. Thread originally posted on 11 October 2011]

Using Net Express 5.1/Windows XP Pro SP3.

I have a program in which I'm dynamically allocating memory to contain a variable length table.

Calling "CBL-ALLOC_MEM" works fine - I am able to populate the table and display its contents, as required.

When I try to 'free' the memory I get a "252 Memory corruption detected (addr=xxxxxxx type 30/4)".

The program stops - as shown in Animator - on the 'call "CBL_FREE_MEM"' line as shown:

call "CBL_FREE_MEM" *> crashes on this line - memory corrupted
using by value memory-pointer
returning status-code
if not status-code = 0
move "Failed to release memory" to message-line
perform display-message
stop run
end-if.

The program doesn't even reach the 'if not status-code = 0' line.

I've set up a cobopt.cfg file containing 'set memory_strategy=0x40000000' but this has no effect.

Not sure how to proceed from here. I don't want to set up a 'static' table in Working Storage since that would be a complete waste of space for a function that will probably be only used once on each running of the program. Any clues appreciated.

TIA
You need to find out where in your program the memory is becoming corrupt.

If you call CBL_ALLOC_MEM and then immediately call CBL_FREE_MEM does it work?

You can test for memory corruption at various points in your program by calling the following:

CBL_MEM_VALIDATE

Validates memory allocations, monitored freed memory, and, if the operating system supports it, compacts memory heaps.

Syntax:

call "CBL_MEM_VALIDATE" using by value flags
by reference param
returning status-code


Please see documentation for more detailed information on the setting of flags etc.

[Migrated content. Thread originally posted on 11 October 2011]

Using Net Express 5.1/Windows XP Pro SP3.

I have a program in which I'm dynamically allocating memory to contain a variable length table.

Calling "CBL-ALLOC_MEM" works fine - I am able to populate the table and display its contents, as required.

When I try to 'free' the memory I get a "252 Memory corruption detected (addr=xxxxxxx type 30/4)".

The program stops - as shown in Animator - on the 'call "CBL_FREE_MEM"' line as shown:

call "CBL_FREE_MEM" *> crashes on this line - memory corrupted
using by value memory-pointer
returning status-code
if not status-code = 0
move "Failed to release memory" to message-line
perform display-message
stop run
end-if.

The program doesn't even reach the 'if not status-code = 0' line.

I've set up a cobopt.cfg file containing 'set memory_strategy=0x40000000' but this has no effect.

Not sure how to proceed from here. I don't want to set up a 'static' table in Working Storage since that would be a complete waste of space for a function that will probably be only used once on each running of the program. Any clues appreciated.

TIA
This will definitely help you.

LINK1
LINK2

this is same what chris is talking about.

Let me know if it works

Thanks
Cheeta

[Migrated content. Thread originally posted on 11 October 2011]

Using Net Express 5.1/Windows XP Pro SP3.

I have a program in which I'm dynamically allocating memory to contain a variable length table.

Calling "CBL-ALLOC_MEM" works fine - I am able to populate the table and display its contents, as required.

When I try to 'free' the memory I get a "252 Memory corruption detected (addr=xxxxxxx type 30/4)".

The program stops - as shown in Animator - on the 'call "CBL_FREE_MEM"' line as shown:

call "CBL_FREE_MEM" *> crashes on this line - memory corrupted
using by value memory-pointer
returning status-code
if not status-code = 0
move "Failed to release memory" to message-line
perform display-message
stop run
end-if.

The program doesn't even reach the 'if not status-code = 0' line.

I've set up a cobopt.cfg file containing 'set memory_strategy=0x40000000' but this has no effect.

Not sure how to proceed from here. I don't want to set up a 'static' table in Working Storage since that would be a complete waste of space for a function that will probably be only used once on each running of the program. Any clues appreciated.

TIA
This will definitely help you.

LINK1
LINK2

this is same what chris is talking about.

Let me know if it works

Thanks
Cheeta

[Migrated content. Thread originally posted on 11 October 2011]

Using Net Express 5.1/Windows XP Pro SP3.

I have a program in which I'm dynamically allocating memory to contain a variable length table.

Calling "CBL-ALLOC_MEM" works fine - I am able to populate the table and display its contents, as required.

When I try to 'free' the memory I get a "252 Memory corruption detected (addr=xxxxxxx type 30/4)".

The program stops - as shown in Animator - on the 'call "CBL_FREE_MEM"' line as shown:

call "CBL_FREE_MEM" *> crashes on this line - memory corrupted
using by value memory-pointer
returning status-code
if not status-code = 0
move "Failed to release memory" to message-line
perform display-message
stop run
end-if.

The program doesn't even reach the 'if not status-code = 0' line.

I've set up a cobopt.cfg file containing 'set memory_strategy=0x40000000' but this has no effect.

Not sure how to proceed from here. I don't want to set up a 'static' table in Working Storage since that would be a complete waste of space for a function that will probably be only used once on each running of the program. Any clues appreciated.

TIA
Chris Glazier originally wrote:

If you call CBL_ALLOC_MEM and then immediately call CBL_FREE_MEM does it work?


Chris: stepping through with Animator suggests that immediately calling CBL_FREE_MEM after the initial allocation does not cause the program to crash.

After further animation it appears that I had a 'perform free-memory' paragraph in 2 places in my code, so the second iteration was trying to free memory that had already been freed ;-(

My silly mistake, I'm afraid. Thanks for responding.

[Migrated content. Thread originally posted on 11 October 2011]

Using Net Express 5.1/Windows XP Pro SP3.

I have a program in which I'm dynamically allocating memory to contain a variable length table.

Calling "CBL-ALLOC_MEM" works fine - I am able to populate the table and display its contents, as required.

When I try to 'free' the memory I get a "252 Memory corruption detected (addr=xxxxxxx type 30/4)".

The program stops - as shown in Animator - on the 'call "CBL_FREE_MEM"' line as shown:

call "CBL_FREE_MEM" *> crashes on this line - memory corrupted
using by value memory-pointer
returning status-code
if not status-code = 0
move "Failed to release memory" to message-line
perform display-message
stop run
end-if.

The program doesn't even reach the 'if not status-code = 0' line.

I've set up a cobopt.cfg file containing 'set memory_strategy=0x40000000' but this has no effect.

Not sure how to proceed from here. I don't want to set up a 'static' table in Working Storage since that would be a complete waste of space for a function that will probably be only used once on each running of the program. Any clues appreciated.

TIA
Cheeta: thanks. I've discovered an error in my code that caused the 252 error (see my reply to Chris)