473,659 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Memory increase over time

I am having a memory problem with my application. Plain and simple all
the program does is runs through a bunch of images and prints them to a
PCL Printer. The first part of the application that I am noticing the
memory increase is when its scanning the specified directory I get an
error like this:

ContextSwitchDe adlock was detected
Message: The CLR has been unable to transition from COM context
0x1b1a58 to COM context 0x1b1bc8 for 60 seconds. The thread that owns
the destination context/apartment is most likely either doing a non
pumping wait or processing a very long running operation without
pumping Windows messages. This situation generally has a negative
performance impact and may even lead to the application becoming non
responsive or memory usage accumulating continually over time. To avoid
this problem, all single threaded apartment (STA) threads should use
pumping wait primitives (such as CoWaitForMultip leHandles) and
routinely pump messages during long running operations.

If I have a smaller amount of images to print the printing *starts*
without any errors. After my application starts printing the memory
eventually gets up to an insane amount (ive seen it up to >300MB) and
then crashes. I am using a helper class that uses the ThreadPool object
to print several documents at a time. It simply acts as a event-driven
WorkQueue with WorkItem objects that contain the information the queue
is to process. I am trying to dispose of objects such as graphics and
PrintDocument but I am still getting this problem. If anyone can help I
would greatly appreciate it.

Jun 22 '06 #1
5 4010
Hi,
You have to post some code
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Benny" <be***********@ gmail.com> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.com.. .
I am having a memory problem with my application. Plain and simple all
the program does is runs through a bunch of images and prints them to a
PCL Printer. The first part of the application that I am noticing the
memory increase is when its scanning the specified directory I get an
error like this:

ContextSwitchDe adlock was detected
Message: The CLR has been unable to transition from COM context
0x1b1a58 to COM context 0x1b1bc8 for 60 seconds. The thread that owns
the destination context/apartment is most likely either doing a non
pumping wait or processing a very long running operation without
pumping Windows messages. This situation generally has a negative
performance impact and may even lead to the application becoming non
responsive or memory usage accumulating continually over time. To avoid
this problem, all single threaded apartment (STA) threads should use
pumping wait primitives (such as CoWaitForMultip leHandles) and
routinely pump messages during long running operations.

If I have a smaller amount of images to print the printing *starts*
without any errors. After my application starts printing the memory
eventually gets up to an insane amount (ive seen it up to >300MB) and
then crashes. I am using a helper class that uses the ThreadPool object
to print several documents at a time. It simply acts as a event-driven
WorkQueue with WorkItem objects that contain the information the queue
is to process. I am trying to dispose of objects such as graphics and
PrintDocument but I am still getting this problem. If anyone can help I
would greatly appreciate it.

Jun 22 '06 #2
Sorry...Here's some code:

**NOTE: work is the queue that holds all work items**

This is when the user clicks start
private void button1_Click(o bject sender, EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(" root");
foreach (TreeNode node in treeView1.Nodes[0].Nodes)
{
pwi = new PrintWorkItem() ;
pwi.FileName = dest + node.Text.Repla ce(".TIF",
".pcl");
dir = new
DirectoryInfo(p wi.FileName.Sub string(0,pwi.Fi leName.LastInde xOf("\\")));
if (!dir.Exists)
dir.Create();
pwi.ImageToPrin t = Image.FromFile( root + node.Text);
pwi.PrinterName = txtPrinter.Text ;
work.Add(pwi);
}
}

This is when the app looks for all files, builds an XML file for later
use as well as populating a treeview so the user may see what images
will be printed:
private void btnSearch_Click (object sender, EventArgs e)
{
lock (work)
{
xw.WriteStartDo cument();
xw.WriteStartEl ement("FILES");
getDirsFiles(ne w DirectoryInfo(r oot));
xw.WriteEndElem ent();
xw.WriteEndDocu ment();
xw.Close();
//work.Resume();
}
DataSet ds = new DataSet();
ds.ReadXml("ite ms.xml");
treeView1.Nodes .Add("Files");
foreach (DataRow dr in ds.Tables[0].Rows)
{

treeView1.Nodes[0].Nodes.Add(dr[0].ToString().Rep lace(root, ""));
}
treeView1.Nodes[0].Expand();
button1.Enabled = true;
}

And this is inside the acutal work item for the PrintDocument.P rintPage
handler:
public void _prntDoc_PrintP age(object sender,
PrintPageEventA rgs e)
{
e.Graphics.Draw Image(_img, e.PageBounds);
e.Graphics.Disp ose();
}

Thanks in advance!

Jun 22 '06 #3
Hi , more info is needed, like are you using a third party tool?

what code does the scanning?
Can you post some pieces of the code that you think may be causing the
problem?

--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Benny" <be***********@ gmail.com> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.com.. .
I am having a memory problem with my application. Plain and simple all
the program does is runs through a bunch of images and prints them to a
PCL Printer. The first part of the application that I am noticing the
memory increase is when its scanning the specified directory I get an
error like this:

ContextSwitchDe adlock was detected
Message: The CLR has been unable to transition from COM context
0x1b1a58 to COM context 0x1b1bc8 for 60 seconds. The thread that owns
the destination context/apartment is most likely either doing a non
pumping wait or processing a very long running operation without
pumping Windows messages. This situation generally has a negative
performance impact and may even lead to the application becoming non
responsive or memory usage accumulating continually over time. To avoid
this problem, all single threaded apartment (STA) threads should use
pumping wait primitives (such as CoWaitForMultip leHandles) and
routinely pump messages during long running operations.

If I have a smaller amount of images to print the printing *starts*
without any errors. After my application starts printing the memory
eventually gets up to an insane amount (ive seen it up to >300MB) and
then crashes. I am using a helper class that uses the ThreadPool object
to print several documents at a time. It simply acts as a event-driven
WorkQueue with WorkItem objects that contain the information the queue
is to process. I am trying to dispose of objects such as graphics and
PrintDocument but I am still getting this problem. If anyone can help I
would greatly appreciate it.

Jun 22 '06 #4
VVV
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi , more info is needed, like are you using a third party tool? I am using a library created by someone on CodeProject. All the
library does is act the same as a queue but has events to execute a job
everytime a job is queued. A work item is basically a PrintDocuemnt
that prints itself on execution. I posted some of the code that shows
the event that is triggered on PrintPage (_prntDoc_Print Page)

what code does the scanning? I simply have a recursive function that uses FileInfo("*.tif ") and
every tiff that is found is added to an array of strings.
Can you post some pieces of the code that you think may be causing the
problem? I think the problem lies in my use of the GC in some way. I am trying
to dispose of some of my objects, mainly my Image, but i dont think are
not being collected because they still are being referenced by
something.


--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Benny" <be***********@ gmail.com> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.com.. .
I am having a memory problem with my application. Plain and simple all
the program does is runs through a bunch of images and prints them to a
PCL Printer. The first part of the application that I am noticing the
memory increase is when its scanning the specified directory I get an
error like this:

ContextSwitchDe adlock was detected
Message: The CLR has been unable to transition from COM context
0x1b1a58 to COM context 0x1b1bc8 for 60 seconds. The thread that owns
the destination context/apartment is most likely either doing a non
pumping wait or processing a very long running operation without
pumping Windows messages. This situation generally has a negative
performance impact and may even lead to the application becoming non
responsive or memory usage accumulating continually over time. To avoid
this problem, all single threaded apartment (STA) threads should use
pumping wait primitives (such as CoWaitForMultip leHandles) and
routinely pump messages during long running operations.

If I have a smaller amount of images to print the printing *starts*
without any errors. After my application starts printing the memory
eventually gets up to an insane amount (ive seen it up to >300MB) and
then crashes. I am using a helper class that uses the ThreadPool object
to print several documents at a time. It simply acts as a event-driven
WorkQueue with WorkItem objects that contain the information the queue
is to process. I am trying to dispose of objects such as graphics and
PrintDocument but I am still getting this problem. If anyone can help I
would greatly appreciate it.


Jun 23 '06 #5
Hi,
"Benny" <be***********@ gmail.com> wrote in message
news:11******** ************@g1 0g2000cwb.googl egroups.com...
VVV
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi , more info is needed, like are you using a third party tool?

I am using a library created by someone on CodeProject. All the
library does is act the same as a queue but has events to execute a job
everytime a job is queued. A work item is basically a PrintDocuemnt
that prints itself on execution. I posted some of the code that shows
the event that is triggered on PrintPage (_prntDoc_Print Page)

what code does the scanning?

I simply have a recursive function that uses FileInfo("*.tif ") and
every tiff that is found is added to an array of strings.
Can you post some pieces of the code that you think may be causing the
problem?

I think the problem lies in my use of the GC in some way. I am trying
to dispose of some of my objects, mainly my Image, but i dont think are
not being collected because they still are being referenced by
something.


Yes, but what about the COM error?
Unless you are using some unmanaged features you should not get it.

You could use a profiler to see where the memory is allocated
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jun 23 '06 #6

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

Similar topics

16
7462
by: Andrew | last post by:
I'm afraid I don't know PHP well enough to figure this out. What I would like is to keep an array in memory so that it doesn't have to be reloaded each time a .php script is run. Is this possible? In Java, I could load the array from a file
9
2615
by: Birgit Rahm | last post by:
Hello newsgroup, I am a beginner, so I am asking maybe immoderate questions. I want to delete a variable, after filling it with complex objects. How should I do it? e.g. AAA = AAA = Can I 1) AAA =
0
1516
by: Kayra Otaner | last post by:
Hi all, I want to get your opinions on how to increase available/free memory and performance on a heavy volume database server. I have MySQL 4.0.13 running on RH 7.2 replicated to another RH 7.2 using same MySQL version. Recently our master database server (2 AMD Cpu + 2Gb memory + 2Gb swap space) started to suffer from memory outages because of heavy load. During day available free memory is changing from 200Mb to 5Mb and when
0
1671
by: kayra | last post by:
Hi all, I want to get your opinions on how to increase available/free memory and performance on a heavy volume database server. I have MySQL 4.0.13 running on RH 7.2 replicated to another RH 7.2 using same MySQL version. Recently our master database server (2 AMD Cpu + 2Gb memory + 2Gb swap space) started to suffer from memory outages because of heavy load. During day available free memory is changing from 200Mb to 5Mb and when...
1
2424
by: picard | last post by:
I have seen in various posts that there are tricks to increasing the largest continuous memory block available to an application on a windows machine. I want to prove this is possible using a simple example. Here is my configuration. -I am running vc++ 6.0 on winXP. (Came with book Starting with Visual C++ by Wright) -I have the 3GB switch set at run time
7
4966
by: Jon Trickey | last post by:
We migrated to 8.1 from 7.2 this weekend. Everything ran ok over the weekend, but we have a light user load then (about 200 users.) Today when we had close to 600 users connecting and running applications, the db2syscs.exe process started gobbling up memory until it hit about 1.7 gigs (which seems to be the limit from what I've read) then it started crapping out.. We have shrunk the buffer pools to much lower that they used to be in 7,...
46
4134
by: sbayeta | last post by:
Hi, I'd like to know who is responsible of memory recycling and defragmentation in a C/C++ program, assuming all the memory allocation/deallocation is done using malloc/free or new/delete. Thanks
6
2103
by: comp.lang.php | last post by:
I have an image that's only 100K in size, and I am working with 8mb of memory. If I do this: print_r(ceil((int)ini_get('memory_limit') * 10 * filesize(actual_path("$locationPath/$this->fileName")) / 1000000) . 'M'); // PRINTS OUT "2M" for 2mb ]/PHP] The image itself requires far less than the maximum amount of memory
17
5698
by: Frank Rizzo | last post by:
Hello, I've compiled my app for AnyCPU setting in vs2005. Then I tried the app on both 32-bit Windows 2003 R2 and 64-bit Windows 2003 R2. The memory usage of the application when working on the same data set were unbelievable (the data is from Task Manager) : 32-bit Windows 2003 R2 Mem Usage: 481,400k Peak Mem: 583,020k
3
2461
by: crazy420fingers | last post by:
I'm running a python program that simulates a wireless network protocol for a certain number of "frames" (measure of time). I've observed the following: 1. The memory consumption of the program grows as the number of frames I simulate increases. To verify this, I've used two methods, which I invoke after every frame simulated:
0
8332
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8525
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4175
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.