|
Saksida Bojan wrote: noticed that it can ran out of memory with large entrys
No, your program ran out of memory. The list will work so long as you have memory for your app.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Is there a whay of increasing App Memory or shoud i resort to I/O Accsess?
|
|
|
|
|
I guess you need to rethink your design. You may want to keep only a portion of the list in memory at a time and swap unneeded parts back to the hard drive, sort of like a memory mapped file.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I Am doing Memory Scanner, Like Cheat Engine. If I acsess Memory and hdd with method Asynth or Synth what woud be better? Does delete command free Memory without closing process?
|
|
|
|
|
What delete command? Where do you read the data from and what do you need to store in your large list?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
The question is, if you buy more RAM, how much will your users need ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
My Process was about 500MB in memory. I Have 2GB of ram. And not all of pshical ram used, let alone windows Virtual Memory
|
|
|
|
|
Well, that is odd. I've had an app in development use 1 gig before. And once you run out of physical memory, it should swap to the HDD.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
public struct ProcessInfo<br />
{<br />
public bool bTaskBar;<br />
public int iProcessID;<br />
public String sTaskBarText;<br />
public String sFileName;<br />
public int iThreads;<br />
<br />
}<br />
<br />
static void Main(string[] args)<br />
{<br />
List<ProcessInfo> lpi = new List<ProcessInfo>();<br />
<br />
do <br />
{<br />
ProcessInfo pi = new ProcessInfo();<br />
lpi.Add(pi);<br />
} while (true);<br />
}
|
|
|
|
|
First, learn how to post code snippets here.
Second, this code:
static void Main(string[] args)
{
List<processinfo> lpi = new List<processinfo>();
do
{
ProcessInfo pi = new ProcessInfo();
lpi.Add(pi);
} while (true);
}</processinfo></processinfo>
Should look more like this:
static void Main(string[] args)
{
List<processinfo> listOfProcesses = new List<processinfo>();
while (true()
{
ProcessInfo processInfo = new ProcessInfo();
if (processInfo != null)
{
listOfProcesses.Add(processInfo);
}
else
{
break;
}
}
}</processinfo></processinfo>
1) You had an endless loop.
2) Your variable names suck.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
1. I know i had endless loop. I wanted to fill my memory and using Virtual Memory as a test. But didnt happend. It threw me System.OutOfMemoryException. And even your sample has infinitive loop. processInfo will never be null, because you intalize it.
2. Read rule #8
|
|
|
|
|
You can also get that exception if you have Int32.Max (2,147,483,648) number of items in the list and then try to add another one.
|
|
|
|
|
Thanks for the info. So it was List limitation, not memory. I Hope i wont have to utilize hdd for temp storage.
|
|
|
|
|
You need to allow programs to access more than 2GB of memory on an OS level. Please read your OS manual to set that.
|
|
|
|
|
When new can't allocate the memory, it returns null .
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hey
All I am trying to do is print a file from c# can't seem to get anything to work. Some of the requirements are:
1) need to have the print dialog box appear
2) print proper file
Thanks,
ZachBob
~Any help is good help
|
|
|
|
|
What sort of file, just text ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
|
Hi,
have a look at the Process and ProcessStartInfo classes, and use Verb="Print"; that way
your default PDF reader will do the actual printing. AFAIK that is the easiest way.
There is one disadvantage: the PDF reader will remain open (unless you add more code to close it,
which is a bit tricky).
|
|
|
|
|
Thanks Luc,
Tried using the Process and ProcessStartInfo classes, but I am getting an Acrobat.exe - Application Error.
Here is my code:
Process printPDF = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.Verb = "Print";
psi.FileName = Server.MapPath(tmpPdf);
psi.CreateNoWindow = true;
printPDF.StartInfo = psi;
printPDF.Start();
What am I doing wrong?
|
|
|
|
|
Hi,
if this is a Windows app, just do psi.FileName=tmpPdf;
I don't know what Server.MapPath is.
is this an ASP.NET application? if so, where is the PDF file, is it on the server?
anyway, double-clicking the PDF file should open your PDF reader, try that and check it
prints OK from there. If not, your file is bad.
|
|
|
|
|
It is actually a web application.
Server.Map - Returns the physical file path that corresponds to the specified virtual path on the Web server.
The pdf opens just fine outside of the web app.
here is some more code to help out:
I start by combining some PDFs into one pdf, then I show it in a pane, then I want the print dialog box to show right after it loads in the pane...
tmpPdf = "/temp/" + Session.SessionID + ".pdf";
PrepareCombinedFile();
FileStream fs = new FileStream(Server.MapPath(tmpPdf), FileMode.Open);
byte[] pdf = new byte[fs.Length];
fs.Read(pdf, 0, Convert.ToInt32(fs.Length));
Response.Clear();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Length",pdf.Length.ToString());
Response.BinaryWrite( pdf );
Response.Flush();
Response.Close();
fs.Close();
try
{
Process printPDF = new Process();
ProcessStartInfo psi = new ProcessStartInfo();
psi.Verb = "Print";
psi.FileName = Server.MapPath(tmpPdf);
psi.CreateNoWindow = true;
printPDF.StartInfo = psi;
printPDF.Start();
}
catch(Exception ex)
{
throw new Exception(ex.Message, ex.InnerException);
}
|
|
|
|
|
Hi,
this code is running on the server, it attempts to print on the server.
I doubt that is what you want.
Your browser should allow you to print a loaded page (or PDF document) on the client side,
either an interactive browser (IE7, FF, ...) or a programmable one (WebBrowser) or a
program using WebRequest and GetResponse.
|
|
|
|
|
correct - I want the print dialog box to appear on the client side. And yes, I am able to print from the loaded page, but the client would like the print dialog box to appear immediately after the pdf loads. Why, I don't know .
|
|
|
|
|
Hi,
I don't know how to do that in a standard browser.
In a WebBrowser Control, I would use the DocumentCompleted event, then write standard
printing code.
|
|
|
|