Memory Access Error (malloc and free) (in different OS)

J

Joe Joe

I write my C program in Visual C.
After a malloc, I loop for 100 times and amend the memory contents
which I have malloced (but I have never change the ptr or its
address).
After that I free the memory space.

The problem is that memory access error happens OS-dependently when I
free the memory space.
When I run the exe in DOS-prompt of Win2000 and NT memory access error
happens.
But when I run it in Visual C debug mode and XP, there is no error.

Does anyone have the same experience before when freeing the memory?
Thank you.
 
R

Richard Bos

I write my C program in Visual C.
After a malloc, I loop for 100 times and amend the memory contents
which I have malloced (but I have never change the ptr or its
address).
After that I free the memory space.

Code, please. I'm not aware of any regular with telepathic powers.
The problem is that memory access error happens OS-dependently when I
free the memory space.
When I run the exe in DOS-prompt of Win2000 and NT memory access error
happens.
But when I run it in Visual C debug mode and XP, there is no error.

Sounds like a corrupted allocation arena. Without code, we still can't
be sure.

Richard
 
R

Raj

Hi Joe,

Primarily, writing past the malloc'd area causes this problem. Though
as you mentioned, differences in behavior between Windows releases do
exist and unfortunately people have been (and still are) living with
it!

-Rajan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top