|
You don't delete anything, that's the beauty. Whenever you do a new you immediately assign the result to a pointer class and even if your code throws an exception the object's destructor is called automagically. This will stop double deletion but won't stop wild pointer writes.
Cheers,
Ash
|
|
|
|
|
I have faith that Aescleal has given you the correct answer for your question.
But here's another couple of thoughts...
1/
Pretty much whenever I delete a pointer, I set it to NULL afterwards. This way I find bugs sooner, and simpler.
So...
ASSERT(pSomething);
if (pSomething)
{
delete pSomeThing;
pSomething = NULL;
}
This will let you catch double deletes.
2/
You could have found the bug yourself. When you got the assert, choose to debug your program. The error shows up in code you did not write. But look at the call stack window. (Debug, Windows, Call Stack on VS2008). Then look up the stack until you get to code *you* wrote. There you will see the mistake.
99% of the time, the bug will be in your code, even if it shows up elsewhere.
Good luck,
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
Iain's point about the debugger reminds me of another point: Always fix bugs as soon as they happen, don't keep piling other stuff on top of buggy code. It's easier to find problems in a 1000 line program than in a 10,000 line one so you'll be more effective if you don't wait until your code is a lot bigger.
Cheers,
Ash
|
|
|
|
|
How to extract BITMAPINFOHEADER structure from BITMAP structure . I have a bitmap file
Rajesh
|
|
|
|
|
Call LoadImage to load the bitmap from the file to get a HBITMAP .
Call GetDIBits on the handle to get a BITMAPINFO structure.
BITMAPINFOHEADER structure is contained with the BITMAPINFO structure.
|
|
|
|
|
BITMAPFILEHEADER bf;
BITMAPINFOHEADER bm;
FILE *fp = fopen(filename, "rb");
fread(&bf, sizeof(BITMAPFILEHEADER ), 1, fp);
fread(&bm, sizeof(BITMAPINFOHEADER), 1, fp);
|
|
|
|
|
Hai All,
I am creating 200 process simultaneously from another process which is running as service in Windows server 2008 R2 machine.
But only 95-100 process are getting created. After that, the remaining process will be terminated abnormally.
Please let me know if there is any limitation in Windows server regarding the number of processes.
-Cvaji
|
|
|
|
|
How did you validate that the processes are terminated abnormally?
Are all processes the same?
If they are the same, you really shouldn't be doing this.
|
|
|
|
|
All process are same.
Why do you say, no to do it????
|
|
|
|
|
Antiviruses will target this as a malicious application.
|
|
|
|
|
«_Superman_» wrote: Antiviruses will target this as a malicious application.
Totally depend upon, what system resource it using!, if it just interacting with some DB, antivirus will do nothing!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Its not interacting with any DB.
"95 processes are started and 96th is not getting started."
Is that related to antivirus? That means antivirus will allow 95 processes and will restrict up to 95?
|
|
|
|
|
No its not related to any antivirus.
Each process will take up a lot of resources.
You're probably running out of it.
Take a look at this blog entry - Pushing the Limits of Windows: Processes and Threads[^]
What I meant about the antivirus is that such behavior is seen mostly in malicious applications and so antiviruses could target such applications.
And so I would never recommend or approve such a design.
|
|
|
|
|
«_Superman_» wrote: Are all processes the same?
If they are the same, you really shouldn't be doing this
I am slightly disagree with this, i am not sure about capibility of Windows 2008 Server r2 and never spawn 100 same process from service.
However, I working/designing an architecture, that will scale Up/Down according workload demand, basically instead on creating thread for each process, I have a controller service, which will spawn the process, to
work independently and process the wrok accordingly.
Basically idea behind the design is intead of stessing on multithreaded architecture, use multiprocess architecture!, if one application crash due some reason, you have atleast same type of application doing similiar work.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I agree with you, but I would be suspicious if 200 processes are created.
It is going to take up too much resources.
|
|
|
|
|
«_Superman_» wrote: I agree with you, but I would be suspicious if 200 processes are created.
It is going to take up too much resources.
yeap i agree, too many process will take too many resources.Also, it's depend how you write your process. Simpler design approch would be, the application should be console based (so we get rid of hugh GDI resources from our progams).
Should have clean architecture and should utilize deadlock prevention techniques!.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Cvaji wrote: I am creating 200 process simultaneously
Hi,
Some humble comments:
1.) I would recommend redesigning your application so that it does not require 200 processes to be created. I cannot think of many reasons why this would be necessary. I can think of hundreds of reasons why this would be undesirable.
2.) The number of processes is mostly limited by the amount of RAM available to the OS. Adding more RAM will probably allow more threads/processes.
3.) You should investigate some of the linker options such as "/STACK" and "/HEAP" to minimize application resource usage. Try to minimize the amount of GDI objects and file descriptors used by your application.
4.) If your process is multi-threaded utilize the STACK_SIZE_PARAM_IS_A_RESERVATION creation flag when you create a thread.
Thats all I can think of for now.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi!
When running my application, it suddenly crashes and goes to this line:
m_pBackButton->draw(); . The variable m_pBackButton 's address is:
0x04ea5608. If I set a data break point at this address, the following are the contents:
0x04EA5608 ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee fe ee îþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþîþî
How to run my application without crash?
|
|
|
|
|
T.RATHA KRISHNAN wrote: m_pBackButton->draw();
Are you sure the m_pBackButton is a valid pointer?
|
|
|
|
|
Looks like m_pBackButton is not initialized.
|
|
|
|
|
No. I've initialised inside another function like this:
m_pBackButton = pManager->getGUIEnvironment()->addButton(recti(0,400,192,432), m_pCreditsImage, CREDITS_BACK_BUTTON, L"Back");
|
|
|
|
|
No information here that I can help you with.
I would recommend putting a breakpoint in the addButton function and debugging the code.
Looks like addButton is failing to return a valid pointer.
|
|
|
|
|
If I hover over m_pBackButton during debugging, it has this value :0x0516b488.
|
|
|
|
|
If you put a breakpoint at draw() are you able to step into it?
|
|
|
|
|
If I press F10 0r F11, it just goes to the next line not to the draw() function definition.
|
|
|
|