473,491 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

EnableThemingInScope not being removed

I'm having trouble with memory runaway and after using .NET Memory Profiler,
I'm finding the class SafeNativeMethods.EnableThemingInScope has instances
allocated frequently while not being removed.

This is in UI app with multiple forms available to be selected via a
toolbar.

How can I ensure that these instances are collected by the GC?
Nov 16 '05 #1
3 1609
EChang,

How are you seeing runaway? They are not collected by the GC if
references are held to them. If they are around, it is because something is
holding them.

What is holding them?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"EChang" <EC****@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
I'm having trouble with memory runaway and after using .NET Memory
Profiler,
I'm finding the class SafeNativeMethods.EnableThemingInScope has instances
allocated frequently while not being removed.

This is in UI app with multiple forms available to be selected via a
toolbar.

How can I ensure that these instances are collected by the GC?

Nov 16 '05 #2
Thx for the response.

Just by keeping Task Manager open I can see the total memory usage of the
app increasing until I get stack overflow errors.

My problem is that I do not even know where these instances are being
allocated. If I knew that, then I might know how to remove the references
keeping it allocated.

I found something helpful online however, though I do not fully understand
it.

"If you look at the samples that ship with the managed dx sdk, you will
notice that they use Application. DoEvents to drive the app. In the effect
editor, I was seeing objects of type EnableThemingInScope that were created
in something called by Application.DoEvents that weren't behaving as short
lived objects, they were surviving GCs. I spoke with the Windows.Forms guys,
asked them about this behavior and they told me that this was a heavyweight
API and that I shouldn't be using it for this purpose. They suggested hooking
up to the OnIdle event and checking the message queue with an unmanaged API
until they provide something like IsIdle()."

From:
http://www.xplsv.com/blogs/devdiary/...1_archive.html

I don't understand what a heavyweight API is. Also, Application.DoEvents is
called so that while something in my code is processing, other events can be
handled. I still want that functionality in my app. How can I keep
Application.DoEvents but not have the problems with instances of
EnableThemingInScope eventually killing my app?
"Nicholas Paldino [.NET/C# MVP]" wrote:
EChang,

How are you seeing runaway? They are not collected by the GC if
references are held to them. If they are around, it is because something is
holding them.

What is holding them?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"EChang" <EC****@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
I'm having trouble with memory runaway and after using .NET Memory
Profiler,
I'm finding the class SafeNativeMethods.EnableThemingInScope has instances
allocated frequently while not being removed.

This is in UI app with multiple forms available to be selected via a
toolbar.

How can I ensure that these instances are collected by the GC?


Nov 16 '05 #3
Stack overflow has nothing to do with GC, objects are NOT stack allocated.
SafeNativeMethods.EnableThemingInScope is not a class it's a method, so how
can you even see instances of it?
Your problem is mostly due to uncontrolled (or infinite) recursion.

Willy.

"EChang" <EC****@discussions.microsoft.com> wrote in message
news:87**********************************@microsof t.com...
Thx for the response.

Just by keeping Task Manager open I can see the total memory usage of the
app increasing until I get stack overflow errors.

My problem is that I do not even know where these instances are being
allocated. If I knew that, then I might know how to remove the references
keeping it allocated.

I found something helpful online however, though I do not fully understand
it.

"If you look at the samples that ship with the managed dx sdk, you will
notice that they use Application. DoEvents to drive the app. In the effect
editor, I was seeing objects of type EnableThemingInScope that were
created
in something called by Application.DoEvents that weren't behaving as short
lived objects, they were surviving GCs. I spoke with the Windows.Forms
guys,
asked them about this behavior and they told me that this was a
heavyweight
API and that I shouldn't be using it for this purpose. They suggested
hooking
up to the OnIdle event and checking the message queue with an unmanaged
API
until they provide something like IsIdle()."

From:
http://www.xplsv.com/blogs/devdiary/...1_archive.html

I don't understand what a heavyweight API is. Also, Application.DoEvents
is
called so that while something in my code is processing, other events can
be
handled. I still want that functionality in my app. How can I keep
Application.DoEvents but not have the problems with instances of
EnableThemingInScope eventually killing my app?
"Nicholas Paldino [.NET/C# MVP]" wrote:
EChang,

How are you seeing runaway? They are not collected by the GC if
references are held to them. If they are around, it is because something
is
holding them.

What is holding them?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"EChang" <EC****@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
> I'm having trouble with memory runaway and after using .NET Memory
> Profiler,
> I'm finding the class SafeNativeMethods.EnableThemingInScope has
> instances
> allocated frequently while not being removed.
>
> This is in UI app with multiple forms available to be selected via a
> toolbar.
>
> How can I ensure that these instances are collected by the GC?


Nov 16 '05 #4

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

Similar topics

14
2301
by: Joshua Beall | last post by:
Hi All, I read in a forum somewhere that namespaces, though once supposed to be a part of PHP5, have been removed. Is this true? Can anyone show me the official statement by Zend that they...
4
1488
by: Alex Sedow | last post by:
Method invocation will consist of the following steps: 1. Member lookup (14.3) - evaluate method group set (Base.f() and Derived.f()) .Standart say: "The compile-time processing of a method...
2
1233
by: Sammy | last post by:
Everyone, I have this very strange problem and we spent weeks to figure out what's going on. Let me outline the configuration of our system: 1. .NET Framework v. 1.0.3705 2. SQL 2000 SP 3...
0
1255
by: Ryan Liu | last post by:
Hi, I notice a DataRow in Detached when it is just created by dataTable.NewRow(), and when added to a dataTalbe's row collection, then removed from that collection. For the first situation, I...
5
4411
by: Scirious | last post by:
People, how many deprecated methods have really been removed and no longer exists? TIA, Scirious.
6
1520
by: Alien | last post by:
According to MSDN, removing elements invalidates only those iterators that had specifically pointed at the removed elements. But I tried following codes, and find that without the repeated...
9
1446
by: anon.asdf | last post by:
Hi! The following code is a snippet where the goto's cannot be removed "without increasing code-size, or decreasing performance". /*********A**************/ int var_other_thread; // value...
0
1026
by: bloodsugarsuckerfish | last post by:
Hi all, I have in the ASP.NET cache a Hashtable of items. What seems to be happening,is that some of the actual entries in the hashtable are being removed, perhaps under memory pressure, when...
0
7115
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
6978
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
7154
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,...
0
7360
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
5451
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,...
1
4881
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...
0
3076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
280
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.