Click here to Skip to main content
15,900,616 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to replace a .exe's icon from ICO file? Pin
David Crow8-Dec-03 2:30
David Crow8-Dec-03 2:30 
Generaldetecting outgoing connections Pin
Jump_Around4-Dec-03 5:17
Jump_Around4-Dec-03 5:17 
GeneralRe: detecting outgoing connections Pin
BaldwinMartin4-Dec-03 5:47
BaldwinMartin4-Dec-03 5:47 
GeneralQuestion about ShellExecute() Pin
KellyR4-Dec-03 4:49
KellyR4-Dec-03 4:49 
GeneralRe: Question about ShellExecute() Pin
BaldwinMartin4-Dec-03 5:14
BaldwinMartin4-Dec-03 5:14 
GeneralRe: Question about ShellExecute() Pin
KellyR4-Dec-03 5:38
KellyR4-Dec-03 5:38 
GeneralRe: Question about ShellExecute() Pin
BaldwinMartin4-Dec-03 5:42
BaldwinMartin4-Dec-03 5:42 
QuestionMemory or Disk? Pin
speedpacer4-Dec-03 4:33
speedpacer4-Dec-03 4:33 
There seems to be a lot of articles written which promote the use of storing DHTML data from a C++ application in memory, rather than reading/writing temporary files to disk. However, there doesn't appear to be a lot of support backing this "best-practices" theory, other than disk caching seems slower or more sloppy (for lack of a better word) than memory caching, and that the temporary files will need to be deleted afterwards. I'm going to have to raise a brow on this one and get some others thinking about it before we all start writing a bunch of applications based on this memory usage theory.

The idea is that by initially navigating to "about:blank" and insuring that the document is loaded, we can then write directly to the HTML document as it sets in memory. The alternative approach obviously, is to write to a temporary file that is stored on the hard disk, "C:\\temp\\temp.htm" for example. I've looked deeply into both of these methods and I have to say that I'm leaning a little towards the disk caching but maybe someone can raise a point that I haven't considered.

Firstly, most of the articles claim that there'd be a need to write temporary "files" (plural), which is a little misleading. If you can write your entire DHTML document to one "about:blank", then you should be able to write the same content to one "temp.htm".

In terms of clean-up, deleting a temporary file is no different than releasing values stored in memory and Microsoft has confirmed that there are issues with releasing BSTR's from memory, even in Internet Explorer, which is causing memory leaks in most of these memory-based solutions. Simply put, a rebel file will cause far less damage than an orphaned memory block. After all and in most cases, we have Gig's worth of free and available disk space to work with and only a few hundred Meg's worth of memory, not to mention the fact that that few hundred MB's is being shared with the operating system and all of the other applications that are running on the desktop and using memory.

Additionally, the nature of a Microsoft OS is to buffer memory in an out of a paging file, so the data is eventually going to be written to the disk anyway, and into a space that is restricted by the amount of memory that is available to the system. True, the OS will "take care of it for you" but when you let something else take care of something for you, you give up the control you have over how it's handled.

And does your file need to be temporary? Do you even need to delete the file? In some cases, it may be advantatious to have a file still cached on the disk, to allow the users to work "off-line" for example, or if there's an Internet gliche and some of the data that you're attempting to download is unavailable, you can resort back to the cached file and let the end-user know that it's old data. If everything is stored in memory however, it's lost (hopefully) when they close the application. If the data they need is unavailable the next time they fire it up, they get nothing.

As far as speed goes, the disk reader and the ribbon cable slow the data down a little but the data, whether traveling from the RAM or the hard disk, will most likely bottleneck on the system bus, especially if there are a lot of other applications/services running and it's rush hour and everybody wants to go to CPU Town.

Disk access speed has increased right along with all of the other processing speeds over the years and frankly, I'd rather my customers complain about my application being a little slower in response time (if it's even noticable) than spreading around words and phrases about my application like "resource hog" and "memory leaks", which can be a deal breaker.

Besides that, the less memory that the system has available, the longer the computer will take to process data and the slower the machine will be overall, so instead of just having a slightly slower application, you're stepping on the turf of other applications and slowing down the whole system by storing large amounts of data in memory.

And finally, Microsoft itself uses temporary Internet files for caching information and they've developed both the Operating System and a pretty popular little web browser too, so maybe they know something we don't know?

Whether stored in memory or on disk, it's the same number of 1's and 0's either way you slice it. The only disadvantage that I can see with storing this type of data on disk is a slightly slower response time but I'm not even sure that it would be enough of a difference that would be noticable by the human eye, which is obviously the most important aspect, what is presented to the end-user. And storing this same data in memory can ramify into more problems which could have a negative impact on the entire sytem.

All things considered and in conclusion, wouldn't it be best to store DHTML data on disk rather than in memory?

Thoughts, ideas, retorts?

Cheers,
Wolf

"Anything's possible if you don't know what you're talking about."
- Green's Law of Debate

AnswerRe: Memory or Disk? Pin
Daniel Turini4-Dec-03 5:08
Daniel Turini4-Dec-03 5:08 
AnswerRe: Memory or Disk? Pin
Joel Lucsy4-Dec-03 10:23
Joel Lucsy4-Dec-03 10:23 
Generaldesperation setting in Pin
Jason Henderson4-Dec-03 4:29
Jason Henderson4-Dec-03 4:29 
GeneralRe: desperation setting in Pin
Jason Henderson4-Dec-03 4:44
Jason Henderson4-Dec-03 4:44 
GeneralRe: desperation setting in Pin
Jim A. Johnson4-Dec-03 8:08
Jim A. Johnson4-Dec-03 8:08 
GeneralRe: desperation setting in Pin
BaldwinMartin4-Dec-03 5:17
BaldwinMartin4-Dec-03 5:17 
GeneralRe: desperation setting in Pin
Jim A. Johnson4-Dec-03 8:09
Jim A. Johnson4-Dec-03 8:09 
GeneralDll Pin
Bo Hunter4-Dec-03 4:15
Bo Hunter4-Dec-03 4:15 
GeneralRe: Dll Pin
valikac4-Dec-03 6:25
valikac4-Dec-03 6:25 
GeneralHelp me please!!! Deconvolution Pin
Angeluna4-Dec-03 3:57
sussAngeluna4-Dec-03 3:57 
GeneralRe: Help me please!!! Deconvolution Pin
BaldwinMartin4-Dec-03 5:44
BaldwinMartin4-Dec-03 5:44 
Generalbest place to delete "this" Pin
ns4-Dec-03 3:21
ns4-Dec-03 3:21 
GeneralRe: best place to delete "this" Pin
David Crow4-Dec-03 4:03
David Crow4-Dec-03 4:03 
GeneralRe: best place to delete "this" Pin
BaldwinMartin4-Dec-03 5:20
BaldwinMartin4-Dec-03 5:20 
GeneralMAPI Pin
Jump_Around4-Dec-03 2:33
Jump_Around4-Dec-03 2:33 
GeneralRe: MAPI Pin
David Crow4-Dec-03 4:05
David Crow4-Dec-03 4:05 
GeneralURGENT !! Please Need help printing bitmap Pin
crazydave224-Dec-03 1:34
crazydave224-Dec-03 1:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.