Solved

Regarding Memory!

Posted on 2000-04-16
2
178 Views
Last Modified: 2010-04-02
What is memory leak & memory overwrite?(in C or c++)
0
Comment
Question by:vinusa500
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
Toad224 earned 25 total points
ID: 2784880
A memory leak is a memory leak in general.  It is not specific toward a certain programming language (as you have stated 'in C'.)

A memory leak is when you load something, and do not close it.  For example (using the Windows API):

HANDLE A = LoadIcon(...);

This will Load the icon into 'A'.  However, this consumes memory.  If you do not call 'CloseHandle' after you have finished using 'A', the memory will not be available for other things, and will still hold the icon information.  Let's say you had a timer, which constantly loaded something without closing it.  It would constantly take up memory.  This is what we call a 'memory leak'.  Eventually, there will be no memory left, and could cause General Protection Faults (Windows) or Kernel Panics (Linux).

A memory overwrite is when you have a variable such as:

LPSTR A[25];

The definition is exactly what it sounds like.  If you accidentally had written over a part of that memory.
0
 
LVL 1

Expert Comment

by:Vinay
ID: 2788329
i like this answer but will u plz more clerify it in proper C examples using array or pointer notations.
Thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question