I've written a library in VC++.NET2003 with 1 exposed class and 2 Inner classes:
WinInet Wrapper used in making HTTP requests through WinInet APIs (InternetOpenW, InternetOpenUrlW, InternetReadFile).
MSHTML wrapper used in extracting text/links out of HTML. All the interaction with the MSHTML is done through mshtml.h
Exposes various functions to make HTTP requests, transform the HTML data etc.
Above library is used in a C# GUI application. This app spawns upto 50 threads and in each of these threads, C++ library will be called.
I'm very much new to C++, but after going through various articles and source code examples, I've written the library and it is working fine if used sporadically. But in the Multithreading scenario, memory is shooting up and CPU usage was also very high. Read somewhere to rename/delete the below given Reg key:
I'd changed the Zonemap name to Zonemap1. Since then the CPU usage has come down but the memory problem remains.
Prior to writing the C++ library, used MSXML3 (xmlHTTP) and mshtml.dll in C# itself. But Microsft specifically says not to use MSXML in .NET. Though MSXML was quite fast, it also consumed tonnes of memory.
Now I'm at a crossroads and not sure which one is causing the problem:
Using the above in multiple threads.
Could some one tell me what is causing the problem or point out to links\articles?
But in the Multithreading scenario, memory is shooting up
I would "guess", which is not the right way to optimize (use a profiler), that MSHTML is "a" source of significant memory usage.
MSHTML is parsing the HTML and creating an Element structure, probably a tree or something. That is going to take some memory. If you load 50 of them it will take 50 times the memory right?
MSHTML wrapper used in extracting text/links out of HTML
So if you replaced MSHTML with a parser that finds the "text/links" without loading the entire HTML document into memory then that should reduce memory usage. Again without using a profiler this is just a "guess".
In C# I could remove security check on an C DLL call by tagging my function as follow:
static extern void SomeMethod();
In Managed C++ I don't declare the function I just #include the headers.
When I try to compile the program I get c2352 errors (illegal call of non-static member function). I think there is something small that I am missing but I am not sure what it is. I have tried many different versions of this code, and placing it in different parts of the code, etc. Any help would be greatly appreciated.
p.s. I am working on a windows forms application with vs2005 c++ express.
I am a silent member of the group. I have a question and I would like to know the logic behind the development of the program...
The question is as follows:
There are 4 cowboys each wearing a hat which can be of two colours: Green and red. There is a sheriff whose pocket is full of coins. When the sheriff takes out a coin from his pocket, the cowboys changed their hat from one colour to another.
The problem is to write a c++ or a c code to find those cowboys who are wearing the same colour hat at any moment...
If someone can develop the program , I would be grateful...
You're the one who cannot do a simple homework question, we are mostly professional developers here - clearly you are not, maybe you should stick to an easier profession if you cannot do your own homework, maybe be a cleaner or something better suited to you skills (or lack of them).
We are more than happy to help those that at least try to solve the problem themselves, not completely lazy people like you.
you might be able to do what you want to do with a timer function
no chance (if you mean windows WM_TIMER) as it is not high enough resolution, QueryPerformanceCounter() is better but I don't think you will ever get a one nanosecond loop as WIndows is not a realtime operating system.
I am most intrigued by an application that requires an event to occur every second but to 1 billionth of a second accuracy, please tell us more...
If you need +/- 1ns accuracy then because the windows OS family are not real time operating systems this will not be acheivable, perhaps +/- 10ns but realistically +/- 100ns should be assumed.
If this is not adequate, then in order to measure to 1ns with an acceptable error then you actually need sub nanosecond timing solutions. Have you calculated what level of error you can tolerate in the application to which this problem pertains?
case 1:printf("how many nodes you want\t");
printf("enter the element%d\t",i+1);
case 2:printf("enter the element\t");
add at beg (m);
case 3:printf("enter the element\t");
printf("enter the position after which element\t");
case 4:printf("enter the element for deletion\t");
case 5:display(); break;
case 6:count(); break;
case 7:rev(); break;
default :printf("wrong choice");