|
Thomas George wrote:
If you do not want the whole file in emeory at one time, then you can go to any small size you want. But, if you actually want the whole file in memory and you are trying to limit memory usage, so that you do not get an 'out of memory' error, try using memory mapped files.
A small note: using memory mapped files alone does not guarantee that the entire file will (or will not) be mapped into your address space: the amount of the file mapped in can be specified by the user, so that you can map 10KB chunks into your address space as needed, if desired.
If you try to map a large enough file (or part of a file), you can still encounter a out-of-memory-type situation, because you need a contigous range of addresses large enough for the size of the mapping. Paging, however, will still occur as-needed.
Peace!
-=- James (Sonork:100.21837)
"There is nothing worse than being oblivious to the fact that you do not know what you are doing."
[Get Check Favorites 1.5 Now!]
|
|
|
|
|
As I understand it, if the mapping is unnamed, it is mapped into the local address space of the application and is not in the global space. So, the chances of running out of memory is remote - unless you have a 2 GB file. In that case, you are not in a place where generic solutions work.
I am not sure whether I am 100% correct on this. Please feel free to correct me if I am wrong.
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
modified 29-Aug-18 21:01pm.
|
|
|
|
|
[Edit: this had an undesired aggressive tone] I do not believe so: specifying a name only makes the name of the file mapping object (a kernel object) available for others processes to open. Regardless of it bring named or unnamed, it is always mapped into the address space of the calling process.
However, in the case of a named object, the two (or more) different processes share the same physical memory (pages), and physical disk space (the file).
You are correct in saying that (in general) you need a pretty large file to fail, unless your physical address range is fragmented, or you specified a starting address that does not have the contigous range available. BTW: a process' address space is normally 2GB (unless you booted with /3GB).
Peace!
-=- James (Sonork:100.21837)
"There is nothing worse than being oblivious to the fact that you do not know what you are doing."
[Get Check Favorites 1.5 Now!]
|
|
|
|
|
you are right.
The file is always mapped into the process address space, which is 2 GB. But since the mapping is to a logical process address space, i do not think that there will be a failure to map a view, if the physical address space is fragmented. AFAIK, It will just cause more page faults, because each logical page can be mapped to a different physical page.
I am saying this because I have mapped 512 MB on a machine with 512 MB RAM, obviously, there was not enough physical memory to do that. In any case, the idea is to be able to use more memory than available physically.
Thomas
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Thomas George wrote:
[...] if the physical address space is fragmented. AFAIK, It will just cause more page faults, because each logical page can be mapped to a different physical page
Correct. I said "physical address", when I should have said "virtual address", because you need a contigious range of addresses in your virtual address range to satisfy the size of the view.
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Check Favorites 1.5 Now!]
|
|
|
|
|
Supposing our discussion was only limited to text files, moderately large to small text files, would such buffer allocation at one shot be of some advantage? what are the general rules for handling text files?
'My capacity for happiness', he added, 'you could fit into a matchbox without taking out the matches first'.
- Marvin, the robot.
Amit Dey
sonork: 100:18407
msn: visualcdev
|
|
|
|
|
|
What if my files were small to large emails? I would guess such allocation would be fine way of doing things?
'My capacity for happiness', he added, 'you could fit into a matchbox without taking out the matches first'.
- Marvin, the robot.
Amit Dey
sonork: 100:18407
msn: visualcdev
|
|
|
|
|
Supposing our discussion was only limited to text files, moderately large to small text files, would such buffer allocation at one shot be of some advantage? what are the general rules for handling text files?
'My capacity for happiness', he added, 'you could fit into a matchbox without taking out the matches first'.
- Marvin, the robot.
Amit Dey
sonork: 100:18407
msn: visualcdev
|
|
|
|
|
IMHO, only if you were making changes to the file.
Peace!
-=- James (Sonork:100.21837)
[Tip for SUV winter driving survival: "Professional Driver on Closed Course" does not mean "your Dumb Ass on a Public Road"!] [Get Check Favorites 1.5 Now!]
|
|
|
|
|
Thanks,James.
'My capacity for happiness', he added, 'you could fit into a matchbox without taking out the matches first'.
- Marvin, the robot.
Amit Dey
sonork: 100:18407
msn: visualcdev
|
|
|
|
|
Howdy,
Is it possible for a UI thread to do a SendMessage to it's self? If so SendMessage requires HWND.. does a UI thread have a HWND? I guess I'm a little confused.. Anyone have any suggestions?
Thanks!!
Rob
|
|
|
|
|
Like PostThreadMessage ?
Peace!
-=- James (Sonork:100.21837)
"There is nothing worse than being oblivious to the fact that you do not know what you are doing."
[Get Check Favorites 1.5 Now!]
|
|
|
|
|
Thanks..
I'm really using WSASelect() which requires a HWND.. I posted SendMessage (Dumb of me )because I wanted to see if someone would say it's possible to get a HWND from a thread.. Have you ever used WSAAsyncSelect() inside a UI Thread?
|
|
|
|
|
RobJones wrote:
Have you ever used WSAAsyncSelect() inside a UI Thread?
Maybe, some time ago. Now, I would just use WSAEventSelect(...) and use Event objects to indicate whenever something is ready for me. (This works just like normal Win32 events.)
IIRC, UI Threads usually manage their own GUI objects (windows), so they should already have their own message pumps. Worker threads are the ones that do not normally have message pumps. And a thread that occassionally "touches" a GUI object it did not create is not a GUI thread.
Peace!
-=- James (Sonork:100.21837)
"There is nothing worse than being oblivious to the fact that you do not know what you are doing."
[Get Check Favorites 1.5 Now!]
|
|
|
|
|
Thanks.. I'll look into event objects..
|
|
|
|
|
send UI instance (this) into thread as parameter
|
|
|
|
|
I have a dialog that make some validation when a user clicks OK. If the validation fails, the dialog tells the user, and must not close. How can I make a dialog not close when the user clicks OK.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
if you don't call the CDialog::OnOk in your own OnOK, the dialog won't close.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
tx Chris
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Hi I'm using ShellExecuteEx to print the files..
for some files, I got error message saying "file association not found".
So I went to the directory where the file got saved and I set the associate editor by doing so,
click once on file name, right click, open with, choose the application or exe file ( notpad, wordpad,excel...etc.).
lets say, text document, so I open with notepad... it fine for once but not for next text file. I have to repeat the setting editor again...
Is there anyway that I can set the file editor programmatically???
can ShellExecuteEx do so??
|
|
|
|
|
When you right-click the file and select "open with, choose program", you can select the program to open the file with. On this same dialog box, there should be a checkbox to set, asking "Always use the selected program to open this type of file". Make sure this is checked and you shouldn't have any more problems.
ShellExecuteEx will not allow you to set associations. I'm assuming that you could change registry keys, but I'm not sure what, where, or how.
|
|
|
|
|
Hello,
I have a program works fine in Windows XP/2K but having a lot of problem with Windows 98/ME after I've created couple hundred bitmap and inserted to a image list. I do not think it's because not enough memory since I create and destroy them one by one. I sure walk thought the program and I've released all image handle properly.
I also notice that some font has changed to the fixed font and cannot create window after the problem occur. I believe there's some kind of memory leak which only occur in Windows 9x. I used Purify but can't find any leak.
Do you have any clue what's going on? I'm guessing that I forget to release some handle in my program so Window 9x can't let me create font and window? Is there any program runs in Windows 9X shows me how many bmp, font etc handle holding in a program?
Thanks,
Hiusing
|
|
|
|
|
Sounds like a GDI resource leak to me! Some usual indications are: fonts start changing, things do not repaint correctly, and window creation fails.
Posting the code snippets of how you create and destroy the bitmaps may help us help you determine if they actually are being destroyed and freed correctly.
BTW: the resource leak could be with some other GDI code as well...
Peace!
-=- James (Sonork:100.21837)
"There is nothing worse than being oblivious to the fact that you do not know what you are doing."
[Get Check Favorites 1.5 Now!]
|
|
|
|
|
Hiusing wrote:
I do not think it's because not enough memory since I create and destroy them one by one. I sure walk thought the program and I've released all image handle properly.
I am afraid that is not the case. W2000 catches these things and cleans them for you, this is a classic case of bitmaps or other GDI resources not being cleaned up properly.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|