|
What do you want to do ? You want to dictate what memory a program runs in ? Process.Start will run an exe.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
System.Diagnostics.Process.Start("YourApplicationFile.exe");
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
How to know a EXE file was written by .net language or not?
|
|
|
|
|
In what context ? You can run reflector on it and see if you can see the source code. You can examine the header, if you want to do it within a program.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Then you need to find out exactly how the file itself marks that it is .NET, and write code to read the head of the file and examine it for this info.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i think i know the way you said before,but,i do not know the code.
|
|
|
|
|
Good question, I've been having the same question.. for java, it's easily Identified by it's ugly purple controls "if not using UIs" but .Net
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
just wait for the answer.
|
|
|
|
|
I cant remember where exactly, but thers PE00 somewhere in the header.
---
The sum of the intelligence of the world is constant. The total number of people is always increasing.
|
|
|
|
|
You could use .NET Reflector[^] to point it at the .EXE and see if it will disassemble.
|
|
|
|
|
yes,the Reflector could do that,but,i want do that with my C# code .
|
|
|
|
|
Hello everyone:
I have a quick question about rich text box controls in visual basic. I basically want to change the colour of the text in one of these controls, but I can't see another way to do it then use the "Select" command. This basically highlights text and then you can make whichever changes you want. The problem is of course that this has all sorts of unpredictable behaviors which can't be foreseen, and of course, its outright sloppy. The problem is I see no other way to edit the internal data easily! What's the standard correct way to do this sort of thing?
Regards,
James
Did I post well? Rate it! Did I post badly? Rate that too!
|
|
|
|
|
You're post should be in the VB forum. And I'm no RichTextBox genius, but I seem to recall a loooot of tutorials and references that do it the way you describe, so it might just well be that bad...
gluck!
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
Hi
I am developing a windows test engine application. where i will have all test steps (function calls). where i can select the particular test steps and run for given iterations (say 160). those test steps will be in different class(dll). so i will create objects on every loop(in separate thread) and null it after using it. at the end i will be generating a report for all the test steps for 160 iteration and will finally display a poup showing that whether the test is got passed or failed. On clicking ok on popup the system got hangs. thru debugging i noticed the during test execution CPU is 100% utilized, i thought this might cause of hanging. so Used GC.Collect before displaying the Popup. This have reduced some amount hanging not fully.
Can i use GC.Collect in any other places? is it safe? or any other way to reduce memory leak/cosumption?
and can you please pointout me the good article regarding how to reduce the memory leak/consumption
Thanks
Srini
|
|
|
|
|
engsrini wrote: and can you please pointout me the good article regarding how to reduce the memory leak/consumption
Always call Dispose if it's available. That's the whole article. Oh, and use the using keyword where you can, as in
using (Bitmap bm = new Bitmap(path))
{
//do stuff
}
// it will be disposed here, automatically
You should never call GC.Collect, you're only going to interfere with the efficiency of the garbage collector.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi chris
Thanks for the quick response
Why i should not use GC.Collect? Becuase after using GC.Collect function before calling popup display, it has reduced the objects in memory from 23459922 to 13902334 its amazing.. it didn't harm any other part of code..still everything is working fine. Even i have used finally part to null all the objects..and almost in all my code i have done Object=null. I guess i have used lot of singleton object that might be occupying the memory..lot! so what has to be taken care while using GC.Collect
|
|
|
|
|
engsrini wrote: Why i should not use GC.Collect?
Because this is not C++. The GC is written in a highly optimised way to decide for itself when to collect. The more important question is, are your objects marked for collection ? If you didn't call Dispose, then they need to become orphaned in memory, and noticed as such, in order to be eligible for collection.
engsrini wrote: it has reduced the objects in memory from 23459922 to 13902334 its amazing
Sure, it may force some items that had been marked for 2nd or 3rd generation cleanup to disappear, but this can *hurt* performance. Did your app run faster, or did some number you've fixated on just change ?
engsrini wrote: Even i have used finally part to null all the objects
If you didn't call Dispose, I'm not sure how much that would help. Either way, let the GC do it's job.
engsrini wrote: so what has to be taken care while using GC.Collect
Just don't do it, not unless you have a more compelling reason than 'that number just got smaller'
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: Sure, it may force some items that had been marked for 2nd or 3rd generation cleanup to disappear, but this can *hurt* performance. Did your app run faster, or did some number you've fixated on just change ?
My application is running normal after using it (may be i didn't do thoruough testing and didn't do remote debugging stuffs), I am not using GC.Collect at all the places.. Whenever the user run the test steps with larger iterations, then i will try that command. One more reason for larger memory i am using lot of images for my applicaition since our application is Touch screen we used lot graphics. So as per your suggestion i will put the dispose method wherever necessary, is there any other way to avoid memory leak or any tool to notify me the memory leaks? also is there anyway to idenify the memory used is huge, i suppose to call GC.Collect.
|
|
|
|
|
engsrini wrote: My application is running normal after using it
You are missing the point. Was it running normally before ? Odds are, it's less efficient now, but you can't tell, as it works fine, both ways.
engsrini wrote: So as per your suggestion i will put the dispose method wherever necessary, is there any other way to avoid memory leak or any tool to notify me the memory leaks?
In C++, you got a leak when you didn't call delete. In C#, you get it if you don't call Dispose. Dispose negates any need to GC.Collect, and lets the GC do it's job. There is nothing else to learn, just call Dispose whenever it's there to call. Bitmaps and videos are particular places where this is crucial.
engsrini wrote: also is there anyway to idenify the memory used is huge, i suppose to call GC.Collect.
NEVER call GC.Collect, did I forget to mention that ?
As you were not aware of the Dispose method, I have no doubt that GC.Collect has acted as a band aid on a major problem in your code. Call it, and you will have no issues that GC.Collect could solve.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
So when you call dispose, you actually just mark that for GC, your not directly removing it?
He who laughs last is a bit on the slow side
|
|
|
|
|
No, you're telling it to run custom code which will immediately clean up any unmanaged resources.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Now I know how that works, thanks.
He who laughs last is a bit on the slow side
|
|
|
|
|
One of the reasons to not call GC.Collect() that CG hasn't mentioned directly is that when a garbage collection cycle runs, it runs on a different thread than your application. In order for the GC to determine which objects are available for collection, it must freeze your application's main thread. This means that the more time spent in garbage collection, the less time your application has to run.
Eventually, you will start to see performance problems as your application spends more time in a frozen state.
The best option is to ensure that you dispose of objects as early as possible by calling Dispose or by using the using syntax. As you mentioned, setting the object to null is a good way to inform the GC that the object is eligible for collection because it helps ensure that there are no references to that object remaining.
There are a lot of good references on the Dispose pattern and how the garbage collector works. Look at this article, and the references section:
http://www.codeproject.com/useritems/idisposable.asp[^]
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Scott Dorman wrote: As you mentioned, setting the object to null is a good way to inform the GC that the object is eligible for collection because it helps ensure that there are no references to that object remaining.
I heared that before but never found a documentation on that topic.
Do you have a link to the docu?
Thanks
All the best,
Martin
|
|
|
|