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:
ContextSwitchDeadlock 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 CoWaitForMultipleHandles) 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. 5 3981
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.googlegr oups.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:
ContextSwitchDeadlock 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 CoWaitForMultipleHandles) 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.
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(object sender, EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo("root");
foreach (TreeNode node in treeView1.Nodes[0].Nodes)
{
pwi = new PrintWorkItem();
pwi.FileName = dest + node.Text.Replace(".TIF",
".pcl");
dir = new
DirectoryInfo(pwi.FileName.Substring(0,pwi.FileNam e.LastIndexOf("\\")));
if (!dir.Exists)
dir.Create();
pwi.ImageToPrint = 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.WriteStartDocument();
xw.WriteStartElement("FILES");
getDirsFiles(new DirectoryInfo(root));
xw.WriteEndElement();
xw.WriteEndDocument();
xw.Close();
//work.Resume();
}
DataSet ds = new DataSet();
ds.ReadXml("items.xml");
treeView1.Nodes.Add("Files");
foreach (DataRow dr in ds.Tables[0].Rows)
{
treeView1.Nodes[0].Nodes.Add(dr[0].ToString().Replace(root, ""));
}
treeView1.Nodes[0].Expand();
button1.Enabled = true;
}
And this is inside the acutal work item for the PrintDocument.PrintPage
handler:
public void _prntDoc_PrintPage(object sender,
PrintPageEventArgs e)
{
e.Graphics.DrawImage(_img, e.PageBounds);
e.Graphics.Dispose();
}
Thanks in advance!
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.googlegr oups.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:
ContextSwitchDeadlock 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 CoWaitForMultipleHandles) 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.
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_PrintPage)
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.googlegr oups.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:
ContextSwitchDeadlock 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 CoWaitForMultipleHandles) 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.
Hi,
"Benny" <be***********@gmail.com> wrote in message
news:11********************@g10g2000cwb.googlegrou ps.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_PrintPage)
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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.
...
|
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 *...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
| |