473,484 Members | 1,660 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Memory leak problem

What is a memory leak problem?can anyone explain it with eg
Jul 5 '07 #1
4 1509
r035198x
13,262 MVP
What is a memory leak problem?can anyone explain it with eg
For theoretical type questions, you are best to consult a text.
Jul 5 '07 #2
JosAH
11,448 Recognized Expert MVP
What is a memory leak problem?can anyone explain it with eg
Using Java it's quite difficult to leak memory; here's an obvious example:

Expand|Select|Wrap|Line Numbers
  1. class Foo {
  2.    private static List<Foo> leak= new ArrayList<Foo>();
  3.    public Foo() {
  4.       leak.add(this);
  5.    }
  6. }
  7.  
Now keep on allocating Foo objects and keep forgetting about them. The garbage
collector is very willing to reap them but it can't: the 'leak' list still refers to them all.


kind regards,

Jos
Jul 5 '07 #3
r035198x
13,262 MVP
Using Java it's quite difficult to leak memory; here's an obvious example:

Expand|Select|Wrap|Line Numbers
  1. class Foo {
  2.    private static List<Foo> leak= new ArrayList<Foo>();
  3.    public Foo() {
  4.       leak.add(this);
  5.    }
  6. }
  7.  
Now keep on allocating Foo objects and keep forgetting about them. The garbage
collector is very willing to reap them but it can't: the 'leak' list still refers to them all.


kind regards,

Jos
Ha, your examples leave a lot to be desired.
So the Foo objects will only become eligible for collection when the Foo class is unloaded from the JVM?
Jul 6 '07 #4
JosAH
11,448 Recognized Expert MVP
Ha, your examples leave a lot to be desired.
So the Foo objects will only become eligible for collection when the Foo class is unloaded from the JVM?
Yep, the Foo objects will stay there until the class itself is GC'd.

kind regards,

Jos
Jul 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

10
8684
by: Debian User | last post by:
Hi, I'm trying to discover a memory leak on a program of mine. I've taken several approaches, but the leak still resists to appear. First of all, I've tried to use the garbage collector to...
3
4647
by: Jeremy Lemaire | last post by:
Hello, I am working on cross platform code that is displaying a huge memory leak when compiled on 11.00 HPUX using the aCC -AA flag. It is not leaking on NT, LINUX, Solaris, or HPUX without the...
4
2325
by: Morten Aune Lyrstad | last post by:
Ok, now I'm officially confused. I have a large project going, which uses a win32 ui library I am developing myself. And I'm getting weird memory leaks. I don't know if I can explain what is going...
17
4765
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is...
13
1513
by: Boni | last post by:
I use 3-d party component. In this component I must pass a reference to my object. The problem is that this component has an ugly bug.When this component is disposed, it incorrectly don't delete...
23
4503
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
7
6908
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports...
18
2910
by: diffuser78 | last post by:
I have a python code which is running on a huge data set. After starting the program the computer becomes unstable and gets very diffucult to even open konsole to kill that process. What I am...
3
5285
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". ...
9
4195
by: jeungster | last post by:
Hello, I'm trying to track down a memory issue with a C++ application that I'm working on: In a nutshell, the resident memory usage of my program continues to grow as the program runs. It...
0
7082
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6953
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7105
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6813
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7214
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4529
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3046
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
235
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.