|
Oh yeah - antivirus software will slow it way down
As far as stepping into CRT/MFC code....
Make sure you are linking to the debug version of the library(s).
Put a breakpoint on the fclose() call.
Run in debugger.
When the breakpoint is hit, use F11 to step into the library code.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
you did not mention a temp file before. What is it for?
deleting a file may take several seconds, i.e. Windows may try and try again, when the file happens
to be busy, such as being read by some great utilities (Antivirus and indexing software are very
interested in newly created files).
Without a temp file, there would be no delete involved, hence this possible delay does not occur.
|
|
|
|
|
Thanks Luc.
I checkeked the internal implemation of flcose then I found following comment in fclsoe function:
/* Stream is in use:
(1) flush stream
(2) free the buffer
(3) close the file
(4) delete the file if temporary
*/
from here I got that it deletes temp file in some cases.I cheked on my that it is not creating any temp file.
Another strange thing I found that if I right click on that file to check its properties then it also takes very much time to show properties as compare to other files with same size and at same location.
|
|
|
|
|
OK, Windows Explorer being slow in accessing the file tells us two things:
1. the problem probably is not in your app
2. something is wrong, or you forgot to give some relevant information.
Time to become very specific:
1. what is your OS?
2. what is the full path of your slow file(s)?
3. is it consistent, i.e. is it always slow for a specific file?
4. what is the size of the file?
5. is anything special about its folder? is it shared? is it being virtualized?
etc.etc.
|
|
|
|
|
I wanted to share this great resource with all of you guys.
C++ FAQ Lite is a free C++ online tutorial, for more info, visit the
home page:
http://www.parashift.com/c++-faq-lite/index.html
To download a CHM (legal+free) version of the tutorial, please visit
this page:
http://lawand.wordpress.com/site-map/computer-science/e-books/cpp-faq-lite/
Best Regards.
|
|
|
|
|
Please no advertising on this forum.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
What made you consider this an advertisement ?
This is a free tutorial which content is relevant to this forum right?
|
|
|
|
|
This forum is for posting MFC/C++ questions (as stated in the guidelines).
Advertising (even for free material) should not be posted here. This the reason for my reply (I reported your message too).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
While I appreciate your efforts to spread the cheer, I want to politely tell you that this forum is solely for Visual C++ / MFC / C++ queries.
Your post could have best been into the lounge or general discussions. May I suggest you that you have a link in your signature to download the chm file?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
In an MFC application, how can I disable 'Failed to Launch Help' message for unhandled help IDs and show default page of the help?
Thanks.
|
|
|
|
|
void anotherMethod(auto_ptr<Foo> foo)
{
cout << "Taken ownership. " << foo->getAString() << endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
auto_ptr<Foo> foo(new Foo);
cout << foo->getAString() << endl;
anotherMethod(foo);
cout << "From main again " << foo->getAString();
cout << "Ending main" << endl;
return 0;
} In the avove code, I am trying to pass the auto_ptr to another function. But doing this will make the another function take ownership and the underlying pointer will be deleted when another functions scope ends. So I am unable to access it in the main method again. To workaround this issue, I changed the code like
void anotherMethod(const auto_ptr<Foo>& foo)
{
cout << "Taken ownership. " << foo->getAString() << endl;
} The below code will also work
void anotherMethod(Foo* foo)
{
cout << "Taken ownership. " << foo->getAString() << endl;
}
auto_ptr<Foo> foo(new Foo);
anotherMethod(foo.get()); I am wondering which one is the best approach? Can anyone help?
Also is it a good practice to use auto_ptr over normal pointers and is it always guranteed the cleanup?
|
|
|
|
|
take a look at boost's shared_ptr. it's reference-counted, so you won't run into problems if you pass one to a function, or store one in an STL container.
|
|
|
|
|
Classes from "Boost" looks promising. Thanks for the information.
BTW, just for academic interest, can you look into the example I have given in the initial post? I just want to make sure auto_ptr can be used in such a way.
|
|
|
|
|
yes, i think your examples are correct. since the problem with auto_ptr, in this situation, is that passing an auto_ptr to a function makes a copy, and the copy takes control of the allocated memory. passing it by reference (either as a ref or as a ptr) avoids that copy, and the outer function maintains control of the memory.
|
|
|
|
|
Many thanks
|
|
|
|
|
FYI: Visual C++ 2008 SP1+ has a shared_ptr Class[^] as well.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark. But unfortunatly I can't use it as my application is portable across multiple platforms. I believe the one which you said is not portable (please correct me if I am wrong). Your help is much appreciated though.
|
|
|
|
|
Christian Flutcher wrote: portable across multiple platforms
In that case Boost is a better option for the time being if you need shared_ptr.
shared_ptr will currently only be found on compilers that have implemented the
TR1[^] extensions.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
I have made a dialog based application and in that i have put some buttons, now the problem is i am putting bmp on dialog using picture control and then bmp's on my button control. my pictrue control is hiding my buttons but when i press alt alt my buttons become visible....
how can i remove this problem...
thanks in advance
|
|
|
|
|
What you're saying isn't clear.
Is the picture control so large that it is covering the buttons?
Are the buttons visible in design mode?
|
|
|
|
|
buttons are visible in design
|
|
|
|
|
You didn't answer the other question. Is the picture control so large that it is physically covering the buttons?
|
|
|
|
|
VCProgrammer wrote: how can i remove this problem..
What problem?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
your message is not very clear. My best guess is your PictureBox is autosizing, i.e.
it is growing according to the size of the picture you are showing, and in doing so it
is covering up some Controls it did not cover while designing.
One solution is to disable the autosizing, and possibly choose image stretching instead,
so the image is scaled to fit your picturebox (warning: this does not preserve the aspect ratio).
I don't know the details in C++/MFC.
|
|
|
|
|
Luc Pattyn wrote: I don't know the details in C++/MFC.
u gimme codez sir, no wordz, plz plz sir.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|