473,398 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

disposing of an object

I use a 3rd party grid throughout my apps. My customers are losing memory
each time they open one of the grids. I call
me.c1truedbgrid.dispose()
each time the window closes, but the memory is not released. Is there
something else I should be doing to dispose of this object and reclaim the
lost memory? I've contacted c1 but no answer from them yet.

Thanks for any help.

Bernie Yaeger
Dec 14 '05 #1
12 1253
If this 3rd party control is a COM object, then yes, you must call:

Marshall.RealeaseCOMObject(obj)
"Bernie Yaeger" <be*****@optonline.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I use a 3rd party grid throughout my apps. My customers are losing memory
each time they open one of the grids. I call
me.c1truedbgrid.dispose()
each time the window closes, but the memory is not released. Is there
something else I should be doing to dispose of this object and reclaim the
lost memory? I've contacted c1 but no answer from them yet.

Thanks for any help.

Bernie Yaeger

Dec 14 '05 #2
Bernie,

Dispose does never release memory.

The only thing it does is giving the GC a signal that it in your opinion can
be released. However, the GC will check for that again and if it can not be
released it stays.

Reasons for the last can be a reference to an existing object or an
reference from an existing object.

Cor
Dec 14 '05 #3
"Bernie Yaeger" <be*****@optonline.net> schrieb:
I use a 3rd party grid throughout my apps. My customers are losing memory
each time they open one of the grids. I call
me.c1truedbgrid.dispose()
each time the window closes, but the memory is not released. Is there
something else I should be doing to dispose of this object and reclaim the
lost memory? I've contacted c1 but no answer from them yet.


Is this a .NET control or an ActiveX control? In addition to that you may
want to use a memory profiler to check if the memory occupied by the process
as shown in task manager is really used. Check out
'GC.WaitForPendingFinalizers' + 'GC.Collect' for debugging purposes too.

Allocation Profiler src
<URL:http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=3254325d-a4aa-4bb3-aa86-c72d5104ec74>

CLR Profiler for the .NET Framework 2.0
<URL:http://www.microsoft.com/downloads/details.aspx?familyid=a362781c-3870-43be-8926-862b40aa0cd0&displaylang=en>

CLR Profiler (v2.0)
<URL:http://www.microsoft.com/downloads/details.aspx?FamilyId=86CE6052-D7F4-4AEB-9B7A-94635BEEBDDA&displaylang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 14 '05 #4
"Cor Ligthert [MVP]" <no************@planet.nl> schrieb:
Dispose does never release memory.
Sure, it can. It can release unmanaged resources (and thus memory), but
this depends on the implementation of the 'Dispose' method.
The only thing it does is giving the GC a signal that it in your opinion
can be released. However, the GC will check for that again and if it can
not be released it stays.
No, it doesn't signal the GC anything. 'Dispose' can simply contain code to
clean up unamanged resources such as file handles, unmanaged memory which
has been allocated, ...).
Reasons for the last can be a reference to an existing object or an
reference from an existing object.


More specifically: If the object can be reached from within the
application, then the object doesn't get cleaned up. Circular references
between objects which cannot be reached any more don't prevent the GC from
removing the objects from memory. Sample:

A <-> B <- Application
(Circular reference between A and B, objects can be reached by
the application, thus A and B are not removed by the GC.)

A <-> B Application
(Circular reference between A and B, objects cannot be reached
by the application because the reference has been removed, thus
A and B could be potentially removed by the GC.)

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 14 '05 #5
> Dispose does never release memory.

Well, not Dispose directly, but very often unmanaged resources are released
inside it. That's the purpose of Dispose, to have a place to indicate that
the object should release its references to unmanaged resources.

Dec 14 '05 #6
Herfried,

I know, however for me the question was: why is the datagrid not released?

Reading it, it can be explained in another way too.

Cor
Dec 14 '05 #7
Scott,
Well, not Dispose directly, but very often unmanaged resources are
released inside it. That's the purpose of Dispose, to have a place to
indicate that the object should release its references to unmanaged
resources.


In the each other passing post time, I had already answered in the way you
wrote, that was before I saw your message.

It is confirm your reply to me.

:-)

Cor
Dec 14 '05 #8
Bernie Yaeger wrote:
I use a 3rd party grid throughout my apps. My customers are losing memory
each time they open one of the grids. I call
How are you verifying this?
I've contacted c1 but no answer from them yet.


Good luck with that, their customer support is not very good. They
seem to never return e-mails. They have a forum where you can post
questions, but they never seem to get any official response there
either. I abandonded their products because of it.

Dec 14 '05 #9
Hi Cor,

Thanks for your reply.

This is a .net component. Is it possible that using dispose will help
eventually? Might the GC come around after a few minutes and dispose the
object?

Tx,

Bernie

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:eY**************@TK2MSFTNGP12.phx.gbl...
Bernie,

Dispose does never release memory.

The only thing it does is giving the GC a signal that it in your opinion
can be released. However, the GC will check for that again and if it can
not be released it stays.

Reasons for the last can be a reference to an existing object or an
reference from an existing object.

Cor

Dec 15 '05 #10
Hi Herfried,

It is a .net control. The memory is really used: when my customer opens too
many of these (closing each before opening another), he runs out of memory
and his system freezes up. I have verified this by looking at tak manager,
pf usage. It continues to rise, never diminishes, unless you boot exit the
app.

Thanks for your help.

Bernie
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:u$**************@TK2MSFTNGP10.phx.gbl...
"Bernie Yaeger" <be*****@optonline.net> schrieb:
I use a 3rd party grid throughout my apps. My customers are losing memory
each time they open one of the grids. I call
me.c1truedbgrid.dispose()
each time the window closes, but the memory is not released. Is there
something else I should be doing to dispose of this object and reclaim
the lost memory? I've contacted c1 but no answer from them yet.


Is this a .NET control or an ActiveX control? In addition to that you may
want to use a memory profiler to check if the memory occupied by the
process as shown in task manager is really used. Check out
'GC.WaitForPendingFinalizers' + 'GC.Collect' for debugging purposes too.

Allocation Profiler src
<URL:http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=3254325d-a4aa-4bb3-aa86-c72d5104ec74>

CLR Profiler for the .NET Framework 2.0
<URL:http://www.microsoft.com/downloads/details.aspx?familyid=a362781c-3870-43be-8926-862b40aa0cd0&displaylang=en>

CLR Profiler (v2.0)
<URL:http://www.microsoft.com/downloads/details.aspx?FamilyId=86CE6052-D7F4-4AEB-9B7A-94635BEEBDDA&displaylang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 15 '05 #11
Calling Dispose() has no effect on when the GC will clean your object. Are
you calling the Marshall.ReleaseCOMObject(obj) method?
"Bernie Yaeger" <be*****@optonline.net> wrote in message
news:eA**************@TK2MSFTNGP15.phx.gbl...
Hi Cor,

Thanks for your reply.

This is a .net component. Is it possible that using dispose will help
eventually? Might the GC come around after a few minutes and dispose the
object?

Tx,

Bernie

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:eY**************@TK2MSFTNGP12.phx.gbl...
Bernie,

Dispose does never release memory.

The only thing it does is giving the GC a signal that it in your opinion
can be released. However, the GC will check for that again and if it can
not be released it stays.

Reasons for the last can be a reference to an existing object or an
reference from an existing object.

Cor


Dec 15 '05 #12
"Bernie Yaeger" <be*****@optonline.net> schrieb:
It is a .net control. The memory is really used: when my customer opens
too
many of these (closing each before opening another), he runs out of memory
and his system freezes up. I have verified this by looking at tak
manager,
pf usage. It continues to rise, never diminishes, unless you boot exit
the
app.


It's likely a bug in the component which only the manufacturer can fix.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 15 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Chris Capel | last post by:
I've heard a lot of talk on the forum about memory managment in .NET and disposing things, finalizing them, garbage collection, etc. My question is which managed types need to be disposed after...
4
by: MC D | last post by:
Question: If I have a class which has a property which is a collection of widget objects (an arrayList of widgets), and both the containter class and the widget class implement the IDisposable...
13
by: MuZZy | last post by:
Hi, Just wanted to make sure i get it right: consider this class: // =========== START CODE ============= class Test { private SqlConnection con = null; public void Connect() { con = new...
4
by: sunitabalakrishna | last post by:
Hi, Could someone explain me if I need to implement the Dispose pattern on managed objects that hold objects which have longer life or is a singleton? Example - Class A holds Class Global...
5
by: Chris | last post by:
I have a form that requires drawing custom lines on it. The color of the lines is suppose to be the same as the forcolor of the form. Am I doing this the most efficent and correct way? ...
10
by: sternr | last post by:
Hey, I have a C# assembly that inherits from ServicedComponent and is installed in the Com+ with ServerActivation. And I have a C++ application that calls this Com+ object successfully, But the...
0
by: Gman | last post by:
Hi, Objective: Draw a grid on a bitmap and set this as a panel's image. (Rather than draw the grid directly on the panel and redraw repeatedly in the paint event.) Problem: It works fine....
4
by: Rob | last post by:
Hi all, I wrote myself a little function to do my own housekeeping, I can call it by using Dispose(object) Within this function there's a select case statement which will then, based on...
8
by: Varangian | last post by:
Hello, was wondering of how to dispose of managed resources? or referencing every member of a class to null will release resources...? http://www.marcclifton.com/tabid/79/Default.aspx...
29
by: Jerry Spence1 | last post by:
I'm rather confused as to whether something should be disposed of, or not. What is the general rule? How can you be sure of doing the right thing? I've heard about disposing unmanaged resources but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.