News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to use the least amount of memory

Started by JPlayer, December 20, 2004, 12:28:00 AM

Previous topic - Next topic

JPlayer

Hi. Now that christmas break is here I want to work on a day planner (to do list) program so that I can keep track of everything I have to do since I can never remember to look at real day planners of mine and since i'm always on the computer. I would need it to be in memory all the time (unless I close it) and would want an icon in that special tray near the clock. The problem is that I only have 128 MB of RAM and at any given point in time I have (on average) 4-20 MB free. That means I need this program to take as little memory space as possible. What design approach should I use to accomplish this? I was thinking about dynamic loading (only bring in code into memory when I need it and then take it out) and possibly overlays (although i'm not far enough in the design to know what, if anything, I could overlay). I also don't want it to be unbearably slow (or I won't have any motivation to use it) but I can worry about speed optimizations once I get it built. Does dynamic loading seem like a decent idea? How do you actually do dynamic loading because my book said it can be implemented by the programmer without any operating system support. Are there any other design ideas for this program? Also, what do you call that special tray near the clock and how do you get your program to use it? Sorry for the seemingly infinite amount of questions in this post...lol. Thanks in advance for any help.

hutch--

JP,

What you are after can be done if you write it carefully. MASM is a good tool for small footprint applications and you normally use DLLs you have written yourself to perform the stuff you need at runtiime by dynamically loading and unloading them on a needs basis. It means using the LoadLibrary(), GetProcAddress() and FreeLibrary() functions to dynamicaly load the DLLs but its a very efficient architecture to use with an application aimed at a low resource machine.

With the small editor in MASM32, I use exactly this technique for a number of additions so that multiple instances don't hog memory.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

SamiP

Check out the Shell_NotifyIcon API from MSDN about creating the icon to the taskbars notify area.

Tedd

Just to point out that most of the memory allocated by the program won't even necessarily be in (active) memory most of the time, unless it's actually being used. This is all handled automagically through virtual memory and paging.
I assume the program won't be active too often, so once it hits the GetMessage function, it will basically disappear until it recieves a message, other than that, the memory will be buried in the swap file most of the time.
Of course, trying to get a small footprint isn't such a bad thing ;)
No snowflake in an avalanche feels responsible.

Relvinian

Designing the basic UI and file format is going to be your biggest task. Once you have that designed, you will be able to find out what best suites your method to make the smallest memory footprint available.

A very simple displaying of a task list can be used with a virtual list control and having each line in a "binary record" on disk which you can do a file-seek to read it. That way, only the main UI, the basic controls needed (including any base Windows code) will be loaded at any given time while you are displaying the information.

When you have just the icon in the system tray, you can have a very small footprint loaded and like you possibly said, do dynamic loading of routines that will create, display, edit, etc.

Hope this gives you some more ideas to play with and maybe even allow you to come up with some new ones.

Relvinian