Valhalla Legends Forums Archive | General Programming | Memory Leak

AuthorMessageTime
111787
What exactly does it mean, besides the obvious? What exactly causes a Memory Leak?
May 19, 2005, 1:26 AM
Kp
An ill-maintained memory faucet?
May 19, 2005, 1:29 AM
111787
it makes perfect sense now, any serious answers?
May 19, 2005, 1:30 AM
HdxBmx27
Something that keeps eating away at the end-user's ram. Just blocks of memory sitting there used up, with no purpose. Like loading data from a file and having the thing jsut sit in momory (prime example, during bnet's hashing functions, you have to load the files DWORDS at a time, they add up.)
~-~(HDX)~-~
May 19, 2005, 1:51 AM
K
Memory that is allocated that isn't deallocated.  For example in C/C++ allocating data using malloc/new and forgetting to free/delete[] it.  The memory is still marked as used by the system's memory manager, so it can't be used to fill another memory allocation request.
May 19, 2005, 3:17 AM
Adron
A Memory Leak can be described in many ways.

A. It could be any block of memory that remains allocated when the program finishes execution and has to be automatically freed by the OS.

B. It could be any allocated memory block to which there is no reference or pointer in the program.

C. It could be a program doing something, and after it's done that has a higher memory use than before.

D. It could be C, with the additional requirement that the memory use continues to grow without an upper bound as the program executes.


For A:
[code]
main()
{
    char *a = new char[100];
}
[/code]

For B:
[code]
main()
{
    char *a = new char[100];
    a = 0;
}
[/code]

For C:
[code]
func(int n)
{
   static int *ar[100];
   if(!ar[n]) ar[n] = new int;
}
main()
{
    func(1);
    func(2);
}
[/code]

For D:
[code]
func(int n)
{
   struct item {
       int n;
       struct item *next;
   };
   static item *head;
   item *p;
   p = new item;
   p->n = n;
   p->next = head;
   head = p;
}
main()
{
    func(1);
    func(2);
}
[/code]
May 19, 2005, 4:40 PM
111787
good thing Kp explained so well that I don't have to figure out what the rest of you guys are saying with your crazy big words like allocated memory block.
May 19, 2005, 7:03 PM
Kp
[quote author=111787 link=topic=11635.msg113018#msg113018 date=1116529420]
good thing Kp explained so well that I don't have to figure out what the rest of you guys are saying with your crazy big words like allocated memory block.
[/quote]

If you don't understand the idea of an allocated memory block, you really have no business managing memory.  If you aren't managing memory, you can't affect any potential leaks, which makes explaining them to you pointless.
May 19, 2005, 9:29 PM
Maddox
[quote author=Kp link=topic=11635.msg113035#msg113035 date=1116538152]
[quote author=111787 link=topic=11635.msg113018#msg113018 date=1116529420]
good thing Kp explained so well that I don't have to figure out what the rest of you guys are saying with your crazy big words like allocated memory block.
[/quote]

If you don't understand the idea of an allocated memory block, you really have no business managing memory.  If you aren't managing memory, you can't affect any potential leaks, which makes explaining them to you pointless.
[/quote]

You are not a very good detector of sarcasm.  :P
May 19, 2005, 10:03 PM
Kp
[quote author=Maddox link=topic=11635.msg113042#msg113042 date=1116540225]You are not a very good detector of sarcasm.  :P[/quote]

Based on the original poster's comments, it seemed unlikely he had the presence of mind to be sarcastic, so I took him seriously.
May 19, 2005, 10:57 PM
Maddox
[quote author=Kp link=topic=11635.msg113052#msg113052 date=1116543430]
[quote author=Maddox link=topic=11635.msg113042#msg113042 date=1116540225]You are not a very good detector of sarcasm.  :P[/quote]

Based on the original poster's comments, it seemed unlikely he had the presence of mind to be sarcastic, so I took him seriously.
[/quote]

I think you need to get out more.
May 20, 2005, 3:09 AM
Myndfyr
[quote author=Maddox link=topic=11635.msg113081#msg113081 date=1116558569]
[quote author=Kp link=topic=11635.msg113052#msg113052 date=1116543430]
[quote author=Maddox link=topic=11635.msg113042#msg113042 date=1116540225]You are not a very good detector of sarcasm.  :P[/quote]

Based on the original poster's comments, it seemed unlikely he had the presence of mind to be sarcastic, so I took him seriously.
[/quote]

I think you need to get out more.
[/quote]
I think Kp's response was perfectly understandable.  *shrug*
May 20, 2005, 3:40 AM
Yoni
A memory leak is what happens when you open a drawer, but forget to close it.
May 20, 2005, 6:59 AM
Quarantine
..rofl
May 20, 2005, 10:46 AM
Maddox
[quote author=MyndFyre link=topic=11635.msg113088#msg113088 date=1116560406]
[quote author=Maddox link=topic=11635.msg113081#msg113081 date=1116558569]
[quote author=Kp link=topic=11635.msg113052#msg113052 date=1116543430]
[quote author=Maddox link=topic=11635.msg113042#msg113042 date=1116540225]You are not a very good detector of sarcasm.  :P[/quote]

Based on the original poster's comments, it seemed unlikely he had the presence of mind to be sarcastic, so I took him seriously.
[/quote]

I think you need to get out more.
[/quote]
I think Kp's response was perfectly understandable.  *shrug*
[/quote]

Yeah, if you live under a rock.
May 20, 2005, 1:49 PM
R.a.B.B.i.T
I live under a rock, can I have a cookie?
May 20, 2005, 3:37 PM

Search