Announcement

Collapse
No announcement yet.

Is It Possible To Guarantee A Program's Running Memory Size

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael Mattias
    replied
    Applications can use memory resource notification events to scale their memory usage as appropriate. If available memory is low, the application can reduce its working set. If available memory is high, the application can allocate more memory.
    ...

    Requirements
    Windows NT/2000/XP: Included in Windows XP and Windows .NET Server.
    Windows 95/98/Me: Unsupported

    Code:
     
    %LOWMEMORYRESOURCENOTIFICATION    = 0
    %HIGHMEMORYRESOURCENOTIFICATION   = 1
     
       hNotify = CreateMemoryResourceNotification(%LOWMEMORYRESOURCENOTIFICATION )
        ..
        WaitFor[Single|Multiple]Object[s][Ex]() 
       [b] AND/OR [/b] 
        QueryMemoryResourceNotification()
    MORE: http://msdn2.microsoft.com/en-us/lib...41(VS.85).aspx

    MCM

    Leave a comment:


  • Paul Purvis
    replied
    I have started working on a program to monitor memory and report warning and cautions of low memory. I have some ideas that may work out well and may not. My biggest problem is programming the gui as a newbie on gui and displaying meaningful info to a user if the memory is low or becomes low.

    I just started using the globalmemorystatus function and getting use to what it actually gives me.

    It will take some time to put together a display design that the user will be comfortable with also and one that makes the user act accordingly.

    So far, i have where the program reads a command line for variables to be set. Just a few below

    display startup hidden/show
    display always on top
    display always show
    low memory setting warning
    any amount over low memory allowances
    major warning of low memory warning
    warning of memory where there is not an x amount at memory monitor startup
    location of where the program starts up on screen
    startup font size and window size
    change the default caption used to allow it easier to kill the program

    I would like to have the ability of a second program being able to execute the memory monitor program and kill the program at will.


    Thanks for all the help

    paul

    Leave a comment:


  • Michael Mattias
    replied
    still pondering the situation over

    saw a program written the other day by the new vendor bust because of not enough memory, but the program was only a 16bit program.

    Well, 16-bit MS-DOS has a (1 Mb) hard limit (260 reserved for system, getting the familiar "640K" number), and 16-bit Windows a hard limit of 20 Mb (I think; maybe it's 24 Mb), and in the latter case that's system-wide.

    32-bit windows gives you -per process - the lesser of 2 GB or (Installed RAM + disk space available for use as the page (swap) file).

    AS Mr. Lofgren pointed out, GlobalMemoryStatus can tell you how much virtual memory is will be available to your process...(dwTotalVirtual member of MEMORYSTATUS structure) .. and you can decide what to do. Bear in mind that this number may change during your program run (some other process may grab lots of memory, reducing the disk space available, reducing what is available to you) ... unless you "suck it up now" by allocating that much memory. (VirtualAlloc can do this for you).


    What are you trying to do which you think might bust the (normal) 2 GB bank?

    Or for that matter, do you have to contend with some kind of 'supervisor' program which limits how much memory your process may allocate (see my link for the whole story)?

    I think we are down to requiring more info about the application to provide useful suggestions

    Or spend the relatively few dollars required to get a disk which will be "plenty." eg my home system uses 2-80 Gb FDDs, (peanuts next to some of my clients' systems where they have literally several hundred GB available). Since I put all my application data on "D:" and only program files on "C:", my free space on "C:" is typically 50-60 Gb... or will support 25 or 30 separate simultaneous processes each using "the max." (That would be a lot of memory-intensive processes).


    MCM

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Clipboard Include

    And here's the clipboard Include JIC ssomeone wants to run the above:

    '
    Code:
    '<== Start of Clipboard as an Include ==>
    'Clipboard stuff gotten from Poffs but I forget from whom
    '
    'Note t$ must be initialized - Local t$
    Function Clipboard_Set_Text Alias "Clipboard_Set_Text" _
                  (ByVal sText As String) Export As Long
      Local hData As Long, hGlob As Long
    ' ** Create a global memory object and copy the data into it
      hData = GlobalAlloc(%GMEM_MOVEABLE Or %GMEM_DDESHARE, Len(sText) + 1)
      hGlob = GlobalLock(hData)
      Poke$ hGlob, sText + Chr$(0)
      GlobalUnlock hData
    ' ** Open the clipboard
      If IsFalse(OpenClipboard(%Null)) Then
        GlobalFree hData
        Exit Function
      End If
    ' ** Paste the data into the clipboard
      EmptyClipboard  'WinAPI
      Function = SetClipboardData(%CF_TEXT, hData) 'WinAPI
      CloseClipboard  'WinAPI
    End Function
    Function Clipboard_Get_Text Alias "Clipboard_Get_Text"() Export As String
        Local zPtr As Asciiz Ptr
        OpenClipboard 0 'WinAPI
        zPtr = GetClipboardData(%CF_TEXT)
        If zPtr <> 0 Then Function = @zPtr
        CloseClipboard   'WinAPI
    End Function
    '                   
    '
    Macro Get_Clipboard =  t$ = Clipboard_Get_Text 'put cb in tb at program start 
    '
    Macro Set_Clipboard = Clipboard_Set_Text(t$)
    '
    '<== End of Clipboard as an Include ==>
    
    '

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Paul,

    Maybe you can find some use somewhere in this. It runs every time I start up but you will probably not want that but maybe you can check GlobalMemoryStatus or GlobalMemoryStatusEx in your program(s) and issue a warning based on them.

    '
    Code:
    '                   PBWin 8.?      - WinApi 3/07/2003                                     '
    ' Memory_Display.bas 08/15/05 by Gösta H. Lovgren 
    ' It creates a log file entry in C:\Memory_Log.txt showing processes
    'running
    #Compile Exe               
    '
    #Dim All  ' forces all variables to be explicitly identified, 
              ' (a very good habit to get into) 
     
    #Include "WIN32API.INC" 'needed by all programs
    #Include "CommCtrl.inc"
    #Include "InitCtrl.inc"
    #Include "C:\Power Basic\Includes\clipboard.inc"
     
    Declare Function Programs_Running(Srch$) As Long
    'Needed for Is_Program_Running
    Type EnumType
     hndl       As Dword
     zClass     As Asciiz * %Max_Path
     zCaption   As Asciiz * %Max_Path
     id         As Dword
     hParent    As Dword
     count      As Dword
    End Type
    Global Process_Running$()
     
    %Refresh_Btn = 500
    %Msg_Exit_Button_Id = 600
    %Msg_Label  = 601                                              
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
        'Main Callback Processor
    CallBack Function CB_Main_Processor AS LONG
        Select Case CbMsg     
            Case %WM_COMMAND  
                Select Case CbCtl 
                  Case %Refresh_Btn
                    Select Case CbCtlMsg
     
                    End Select
                End Select
        End Select    
    End Function                     
    '****************************************************************
    '***************************************************************
    'Type MEMORYSTATUS
    '  dwLength As Dword
    '  dwMemoryLoad As Dword
    '  dwTotalPhys As Dword
    '  dwAvailPhys As Dword
    '  dwTotalPageFile As Dword
    '  dwAvailPageFile As Dword
    '  dwTotalVirtual As Dword
    '  dwAvailVirtual As Dword
    'End Type
    '
    'Type MEMORYSTATUSEX
    '  dwLength As Dword
    '  dwMemoryLoad As Dword
    '  ullTotalPhys As Quad
    '  ullAvailPhys As Quad
    '  ullTotalPageFile As Quad
    '  ullAvailPageFile As Quad
    '  ullTotalVirtual As Quad
    '  ullAvailVirtual As Quad
    '  ullAvailExtendedVirtual As Quad
    'End Type
     
    '*****************************************************************
    '*****************************************************************
    Sub Mem_Available
      Local m As MEMORYSTATUS
       GlobalMemoryStatus m  'fil values
     
       Local p$, MegaBytes&,KiloBytes&                                           
       MegaBytes = 1024 * 1024 
       KiloBytes = 1024  
     
       p$ = "Values on 4g installed" & $CrLf & _
            "MEMORYSTATUS yields:" & $CrLf & _
            Using$("#,### Mb Installed ", m.dwTotalPhys \ MegaBytes) & $CrLf & _
            Using$("    #% in use", m.dwMemoryLoad) & $CrLf & _
            Using$("#,### kb Available", m.dwAvailPhys \ KiloBytes) & $CrLf & _
            Using$("#,### Mb User possible", m.dwAvailVirtual \ MegaBytes) 
       Local  p2$
        p2$ = Using$("  #,### Mb Installed", m.dwTotalPhys \ MegaBytes) & _
              Using$("   ##% in use", m.dwMemoryLoad) & _
              Using$("   #,### kb Avl", m.dwAvailPhys \ KiloBytes) 
      Local m_Ex As MEMORYSTATUSEX 'get larger numbers?
      Local GMSX As Long               
      ' dwLength Member Of m_ex To SizeOf(m_ex)
      m_Ex.dwLength = SizeOf(m_ex)
      GMSX = GlobalMemoryStatusEx(m_Ex) 'get values
      Local k&, Meg&, gig&
      k = 1024
      Meg = k * k
      gig = meg * k
      Local p3$, fmt$
        fmt$ = " ###,###,# meg \                      \  "
     
        p3$ = $CrLf & $CrLf & "MEMORYSTATUSEX yields: " & $CrLf & _
              Using$(fmt$, m_ex.ullTotalPhys / meg, "ullTotalPhys") & $CrLf & _
              Using$(fmt$, m_ex.ullAvailPhys / meg, "ullAvailPhys") & $CrLf & _
              Using$(fmt$, m_ex.ullTotalPageFile / meg, "ullTotalPageFile") & $CrLf & _
              Using$(fmt$, m_ex.ullAvailPageFile / meg, "ullAvailPageFile") & $CrLf & _
              Using$(fmt$, m_ex.ullTotalVirtual / meg, "ullTotalVirtual") & $CrLf & _
              Using$(fmt$, m_ex.ullAvailVirtual / meg, "ullAvailVirtual") & $CrLf & _
              Using$(fmt$, m_ex.ullTotalPhys / meg, "ullAvailExtendedVirtual") 
     
         p$ = p$ & p3$ & $CrLf & Using$("#, Returned from GMSX", GMSX)
      Call Clipboard_Set_Text(p$)
      Local FileNum&, File_Name$
      File_Name$ = "C:\Memory_Log.txt"
     
      Call  Msgbox_Dialog("Memories (in " & File_Name$ & ")", p$)
    '  Kill File_Name$ :MsgBox File_Name$,, "Killed " :Exit Sub
     
      Local Mem_Lines&, Mem_Lin$, x&, dt$, tm$, Flag&, New_Day_Flag&   
      New_Day_Flag = 1 'assume a new day  
      dt$ = Date$
      tm$ = Time$
      FileNum = FreeFile
      Open File_Name$ For Input As #Filenum
        FileScan #FileNum, Records To Mem_Lines& 'get number of lines
         'check for same date
        For x = 1 To Mem_Lines
          Line Input #FileNum, Mem_Lin$
           If InStr(Mem_Lin$, dt$) Then 'have line with same date?
             dt$ = Space$(Len(dt$))                  
             Flag = x  
             Reset New_Day_Flag 'not a new date
             Exit For 
           End If
        Next x   
     
        'check for same hour
      If Flag Then
         If Mid$(Mem_Lin$, 12, 2) = Left$(tm$, 2) Then'have line with same hour?
            Mid$(tm$, 1, 4) = "   "
           Else 
            For x = Flag To Mem_Lines
              Line Input #FileNum, Mem_Lin$
               If  Mid$(Mem_Lin$, 12, 2) = Left$(tm$, 2) Then 
                 Mid$(tm$, 1, 4) = "   "                  
                 Exit For 
               End If
            Next x   
         End If 
      End If  
     
     
      Close Filenum          
       Local  z$
        z$ = "Eudora"
        Flag = Programs_Running(p$)
       FileNum = FreeFile
       Open File_Name$  For Append As #FileNum 
       Print #FileNum,  " " 
       If New_Day_Flag Then
          Print #FileNum, $CrLf& $CrLf & "*******************  " & dt$ & "  *******************"
          lset dt$ = " "
       End If    
       Print #FileNum, Dt$ & " " & Tm$ & p2$
          For x = 0 To UBound(Process_Running$())
             Print #FileNum,Using$("#, ", x) & Process_Running$(x)
          Next x
       Close #FileNum
     
    'from WinApi Help
    'The MEMORYSTATUS structure contains information about current memory availability. The GlobalMemoryStatus Function uses this structure. 
    '
    'typedef struct _MEMORYSTATUS { // mst  
    '    Dword dwLength;        // sizeof(MEMORYSTATUS) 
    '    Dword dwMemoryLoad;    // percent of memory in use 
    '    Dword dwTotalPhys;     // bytes of physical memory 
    '    Dword dwAvailPhys;     // free physical memory bytes 
    '    Dword dwTotalPageFile; // bytes of paging file 
    '    Dword dwAvailPageFile; // free bytes of paging file 
    '    Dword dwTotalVirtual;  // user bytes of address space 
    '    Dword dwAvailVirtual;  // free user bytes 
    '
    '} MEMORYSTATUS, *LPMEMORYSTATUS; 
    ' 
    '
    'Members
    '
    'dwLength
    '
    'Indicates the Size Of the structure. The calling process should Set this Member prior To calling GlobalMemoryStatus. 
    '
    'dwMemoryLoad
    'Specifies a number between 0 And 100 that gives a general idea Of current memory
    '    utilization, 
    '  In which 0 indicates no memory use And 100 indicates full memory use. 
    '
    'dwTotalPhys
    'Indicates the total number Of bytes Of physical memory. 
    '
    'dwAvailPhys
    'Indicates the number Of bytes Of physical memory available. 
    '
    'dwTotalPageFile
    'Indicates the total number Of bytes that can be stored In the paging file. 
    '   Note that this number does Not represent the actual physical Size Of the 
    '   paging file On disk. 
    '
    'dwAvailPageFile
    'Indicates the number Of bytes available In the paging file. 
    '
    'dwTotalVirtual
    'Indicates the total number Of bytes that can be described In the User mode 
    '   portion Of the virtual address space Of the calling process. 
    '
    'dwAvailVirtual
    'Indicates the number Of bytes Of unreserved And uncommitted memory 
    '  In the User mode portion Of the virtual address space Of the calling process. 
    End Sub
    '*****************************************************************
     
    '*******************************************************************
    ' Msgbox_Dialog(Hdr$, Msg$) starts here
    ' Just add:
    '%Msg_Exit_Button_Id = 600
    '%Msg_Label  = 601                                              
    ' and it's all set to go
    '*******************************************************************
    Sub Msgbox_Dialog(Hdr$, Msg$)
      Local hCaller As Dword
      Local Dialog_Height&, Dialog_Width& 
       Dialog_Height = 18 * 14 'Lines x 14 = any size you want
       Dialog_Width = 200  '   ""
       Dialog New %hWnd_Desktop, Hdr$, _
           , , _   'no values automatically centers it
           Dialog_Width&, Dialog_Height, _  'size to make it
           To hCaller      'Assign a handle
      Local bg&
       bg& =  252 + (241 * 256) + (167 * 256 * 256) 'light yellow
      Dialog Set Color hCaller,  bg, %Blue
      Local Col&, Row&, Box_Height&, Label_Height&, l$ 
         Col = 10
         Box_Height = 12 'depends on lf.lfheight below  
         Row = 1'Box_Height '* 3                   
         Label_Height& = Dialog_Height - Box_Height - 2
     
      Control Add Label, hCaller, %Msg_Label, Msg$, _
         Col, Row, _
         Dialog_Width - 20, Label_Height&, _
         %SS_Center Or %SS_NOTIFY
      Control Set Color hCaller, %Msg_Label, %Blue,  bg
      Local lf As LOGFONT 'LOGFONT is predefined type in WinApi32
      Local hFont As Dword
        lf.lfHeight  = Box_Height * 2 'seems to work for 6 lines
        lf.lfWidth  = 6   '3
        lf.lfFaceName = "Comic Sans MS" 
        hFont = CreateFontIndirect(lf)
        Control Send hCaller, %Msg_Label, %WM_SETFONT, hFont, 0
     
      Row = Dialog_Height - Box_Height           
      Local Btn_Width&
      l$ = " O&kay   "
       Btn_Width = Len(l$) * 3 'adjust depending on font size used
       Col = (Dialog_Width - Btn_Width) \ 2
    '  Control Add Button, hCaller, %Msg_Exit_Button_Id, l$, _
    '     Col, Row, _ '130
    '     Btn_Width, Box_Height&, _
    '     %BS_Left
     
       Dialog Show Modal hCaller  Call Msgbox_CB
    End Sub
    '  ***
    CallBack Function Msgbox_CB&     
        Select Case CbMsg 
           Case %WM_COMMAND
             Select Case CbCtl 
               Case 1 'enter
                 Dialog End CbHndl
               Case Else
                Select Case CbCtlMsg
                  Case %BN_Clicked, 1, 0 
                    Dialog End CbHndl
                End Select
             End Select ' end Cbctl
        End Select ' end CbMsg
    End Function
    '*******************************************************************
    ' Msgbox_Dialog(Hdr$, Msg$) ends here
    '*******************************************************************
     
    '*******************************************************************
    '*******************************************************************
    'This is adapted from code by Pierre Bellisle 
    'http://www.powerbasic.com/support/forums/Forum4/HTML/004169.html
    '*******************************************************************
    '
    Function Programs_Running(Srch$) As Long
     Local hProc     As Long
     Local hControl  As Long
     Local idControl As Long
     Local SomeText  As Asciiz * %Max_Path '** Pierre had it set at 50 to trap longer strings
     Local EnumTry1  As EnumType               'I changed it for "playing" purposes
     Local EnumTry2  As EnumType  
     
     'The dialog title that we want to find
     EnumTry1.zCaption = Srch$
     
     'Zero mean that we want a window under the desktop
     EnumTry1.hParent  = 0
     
    'If window exist EnumTry will be filled with window handle
     EnumWindows CodePtr(EnumWindowProc), VarPtr(EnumTry1)
     
      Srch$ = EnumTry1.zCaption
     'We got a hit so set value of function
     If EnumTry1.hndl Then
       Function = -1
     End If
    End Function
    '********
    'Retreive windows controls via class
    Function EnumControl(ByVal hWindowProc As Long, ByVal lParam As Long) As Long
     Local LenClass    As Long
     Local LenCaption  As Long
     Local zClass      As Asciiz * %Max_Path
     Local zCaption    As Asciiz * %Max_Path
     Local EnumTryPtr  As EnumType Pointer
     Static Counter    As Long
     
     'Retreive a pointer to EnumTry2 so we can read and change it
     EnumTryPtr = lParam
     
     'Get the class of the control
     LenClass = GetClassName(hWindowProc, zClass, %MAX_PATH)
        '** GetClassName is an API function 
          'hWindowProc has been determined by the call to ... 
            '.. well I don't know where it has been assigned unless it was with the
            'call to EnumChildWindows above
          'zClass must be returned by GetClassName  
          '%Max_Path is a constant of 256, presumably tells GetClassName not to search 
            'more than is necessary?
     
     'Get the text of the control
    ' SendMessage hWindowProc, %WM_GETTEXT, %Max_Path, VarPtr(zCaption)
          '**  SendMessage is an API call 
          '** %Wm_GetText is telling SendMessage what to do.
          '** %Max_Path is how many bytes to do it for  
          '** VarPtr is telling SendMessage where to put the text found
          '   so it can be read in zCaption 
     
     'Did we found our control class?
     If UCase$(zClass) = UCase$(@EnumTryPtr.zClass) Then
       Incr Counter  'We want the third Edit control
       If Counter = @EnumTryPtr.Count Then 'Found the "Interface Prefix" text box
         @EnumTryPtr.hndl     = hWindowProc               'Put handle  in EnumTry2
         @EnumTryPtr.zCaption = zCaption                  'Put caption in EnumTry2
         @EnumTryPtr.zClass   = zClass                    'Put class   in EnumTry2
         @EnumTryPtr.id       = GetDlgCtrlID(hWindowProc) 'Get the control id and put it EnumTry2
         Function = 0 : Exit Function 'Stop enumeration and exit
       End If
     End If
     
     Function = 1 'True, so Function will recall itself until last window found
                     '** Now this is new to me. I was unaware a 
                     '"Function = 1 (%True)" would cause recursion
                     ' And presumably a "Function = 0 (%false)" would cause an exit
                     ' I had seen the Function = 0 in lots of code but until
                     ' now didn't know why.
     
    End Function
    '______________________________________________________________________________
     
    'Retreive windows handle via caption
    Function EnumWindowProc(ByVal hWindowProc As Long, ByVal lParam As Long) As Long
     Local zCaption    As Asciiz * %Max_Path
     Local zClass      As Asciiz * %Max_Path
     Local EnumTryPtr  As EnumType Pointer
     Local LenClass    As Long
     Local LenCaption  As Long
     
     'Retrive a pointer to EnumTry so we can read and change it
     EnumTryPtr = lParam
     
     If IsWindowVisible(hWindowProc) Then                               'Get only visible windows
       If GetParent(hWindowProc) = @EnumTryPtr.hParent Then             'Under desktop if 0 or under parent
         If IsWindowEnabled(hWindowProc) Then                           'Get only enabled windows
           LenClass   = GetClassName (hWindowProc, zClass, %MAX_PATH)   'Get the class of the dialog
           LenCaption = GetWindowText(hWindowProc, zCaption, %MAX_PATH) 'Get the caption of the dialog
     
            Local ll&          
              ll = UBound(Process_Running$()) + 1
           ReDim Preserve Process_Running$(ll)
            Process_Running$(ll) = zClass & " = " & _
                                   Trim$(zCaption)
     
    '         MsgBox  Process_Running$(ll),, "process"   
           'Did we found a dialog with our text?
    ' 1      If UCase$(zCaption) = UCase$(@EnumTryPtr.zCaption) Then
    ' 2      If InStr(UCase$(zCaption), UCase$(@EnumTryPtr.zCaption)) Then
    '   Must use Left$ code case 1 must be an EXACT match 
    '                       case 2 matches anytime Srch$ is in title 
         'searching
           Local l&
           l = Len((@EnumTryPtr.zCaption))
           If Left$(UCase$(zCaption), l) = Left$(UCase$(@EnumTryPtr.zCaption), l) Then
             @EnumTryPtr.hndl     = hWindowProc          'Put handle  in EnumTry1
             @EnumTryPtr.zCaption = zCaption             'Put caption in EnumTry1
             @EnumTryPtr.zClass   = zClass               'Put class   in EnumTry1
             Function = 0 : Exit Function 'Stop enumeration and exit
          End If
     
         End If
       End If
     End If
     
     Function = 1 'True, so Function will recall itself until last window found
     
    End Function
    '______________________________________________________________________________
    ' keep code above to Sub Is_This_Program_Running intact  
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    '                                                                     ¤
    ' PB MAIN Start Here                                                  '
    '                                                                     ¤
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    Function PBMain () As Long
       Call Mem_Available
     
    End Function                     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    '
    and here's yesterday's log for example:

    ******************* 02-14-2008 *******************
    08:43:20 2,047 Mb Installed 10% in use 2,097,151 kb Avl
    0 Shell_TrayWnd =
    1 Progman = Program Manager

    12:12:07 2,047 Mb Installed 10% in use 2,097,151 kb Avl
    0 Shell_TrayWnd =
    1 EXPLOPLUSCLASS = C:\A_Original\The Lovgrens\*.* - ExplorerPlus
    2 #32770 = ExplorerPlus FTP Transfer
    3 #32770 = Trend Micro PC-cillin Internet Security 14
    4 EudoraMainWindow = Eudora - [In]
    5 SlimBrowser MainFrameW = SlimBrowser - Swede's Dock - Pictures of Lavallette, NJ
    6 TEFO_FrmNotepad = NoteTab Pro - C:\A_Original\The Lovgrens\10Trenton\index.html
    7 TApplication = NoteTab Pro - C:\A_Original\The Lovgrens\10Trenton\index.html
    8 Progman = Program Manager

    14:18:52 2,047 Mb Installed 10% in use 2,097,151 kb Avl
    0 #32770 = Windows Task Manager
    1 Shell_TrayWnd =
    2 LogoffMonitorThread_193 =
    3 LogoffMonitorThread_176 =
    4 LogoffMonitorThread_164 =
    5 LogoffMonitorThread_149 =
    6 LogoffMonitorThread_85 =
    7 LogoffMonitorThread_71 =
    8 LogoffMonitorThread_57 =
    9 LogoffMonitorThread_51 =
    10 #32770 = GoToAssist
    11 GoToAssistCustomerUIWindow =
    12 SlimBrowser MainFrameW = SlimBrowser - GoToAssist: connected
    13 Progman = Program Manager

    22:00:54 2,047 Mb Installed 10% in use 2,097,151 kb Avl
    0 Shell_TrayWnd =
    1 EXPLOPLUSCLASS = C:\*.* - ExplorerPlus
    2 Progman = Program Manager

    Leave a comment:


  • Paul Purvis
    replied
    Yes Michael, it seems like we have to roll our own utilities that you would think microsoft would already have already programmed and made easily available to work with their own os systems.
    paul

    Leave a comment:


  • Paul Dixon
    replied
    Paul,
    <<I have always felt that a program using large amounts of memory was poorly written anyways.>>

    Using large amounts of memory is very good programming under some circumstances.

    Memory is a resource to be used as you see fit. If using a lot of memory solves the problem then using a lot of memory might be the right thing to do. Some jobs need a lot of memory and since memory is thousands of times faster than hard disk you can't always leave the data on disk and get your results in time.


    Paul.

    Leave a comment:


  • Michael Mattias
    replied
    Actually, there is a 'canned' Windows event called LOW_MEMORY (or something like that) which is available to any program without doing anything terribly special.

    IIRC the one (huge?) downside of using that is that you, the programmer, don't get to define what "low memory" means. If someone in Redmond thinks it's low, it's low.

    Leave a comment:


  • Paul Purvis
    replied
    I do believe i have seen code to acquire certain resources. I believe a gui program that monitors the memory, disk space and maybe some anything else that would seem relevant, then the gui stays hidden unless certain limits are reached. The gui program upon seeing limits surpassed would become visible giving the info and warning messages as needed to the operator.

    The program could be started prior to certain programs being loaded and possibly killed(unloaded) after the certain program ends.

    Our users run large programs often, virtual computer software being the biggest memory user, and maybe at least a general memory monitor with a warning, that can be set at each computer is what i need. Warning would be something like a mild popup warning, then two levels of warning for resources being used even higher, after that mild warning with no popdown until the memory usage is reduced, if you get my drift.
    paul
    Last edited by Paul Purvis; 15 Feb 2008, 11:51 AM.

    Leave a comment:


  • Michael Mattias
    replied
    It would be nice to load some of the large files in memory ...
    That's not always such a good idea because...
    I have always felt that a program using large amounts of memory was poorly written anyways
    .. your feeling is CORRECT!

    Subjective opinion? Don't worry about all the memory management stuff, other than avoiding the obvious cases where you are loading all kinds of stuff to memory. Win/32 will do a heck of good job for you if you just let it.

    If you run into snags, you can always post specific questions here and someone will give you ideas.

    Here's a thread where I had to do a bunch of stuff because I tried to put too much in memory... no, I wasn't even close to the Win/32 limit, but the client was using a 'scheduler' system which restricted the amount of memory any one "child" process could use.

    http://www.powerbasic.com/support/fo...ML/003994.html

    Hmm, that's the old forum URL, let me see if I can find the new forum url...

    Yup, here it is...

    http://www.powerbasic.com/support/pb...ad.php?t=20645

    MCM

    Leave a comment:


  • Paul Purvis
    replied
    still pondering the situation over.


    I had been writing in cb86 which had memory only 64k for code and 64k for variables and non-gui interface. We changed software vendors 18 months ago from what we had been using since 1983 and in 1985 gave the vendor the boot and i have been in house supporting the databases. Now with the new vendor the, databases are less in number and larger in size. I am moving over to powerbasic, so now i can write programs with more variable memory space.
    Employees at locations are not computer savy and i saw a program written the other day by the new vendor bust because of not enough memory, but the program was only a 16bit program.

    It would be nice to load some of the large files in memory but i have seen programs such as microsoft access in years past come to a complete halt due to memory limitations.

    I have always felt that a program using large amounts of memory was poorly written anyways.

    I have pondered the idea of
    Setting a specific amount of free memory to be available upon program startup.
    Starting a gui program that would be forced on top of the screen with a warning to the user not to start other applications and have that program monitor memory, display the amount of memory in some understandable way and monitor text files that would indicate a second programs completeness that was started by the first gui program that was doing the monitoring.

    Also the program that would be processing the database would have to be written to handle data in specifically sized sections.

    You just never know what somebody is going to try and pull on you and i am always the one that pays the price to fix up screw ups.

    Just another thought, you could actually kill the explorer program so a user would have a hard time starting another program also.
    Then restart the explorer program once the programs have completed.

    paul

    Leave a comment:


  • Michael Mattias
    replied
    > have not had access to the internet over the last week

    Actually I am more interested in how you decide (have decided?) to handle your original memory concerns.

    Since you are one of the few, the not too proud, the careful who actually gave this issue some thought, then asked here because you weren't sure, I think the results of your thought process would be of interest to the new (and some number of the not-so-new as well).

    MCM

    Leave a comment:


  • Michael Mattias
    replied
    >Provided the swap file is enabled...

    Just for the record, I had this come up over the summer when I was in beautiful downtown Columbus MS. (Home of the PigFest). (Nothing quite like Mississippi in August!).

    Client had been having sproradic - and of course, unreproducible - problems with applications halting with a "Cannot load RPC [Remote Procedure Call] Library" error messages (a Windows' error message). This required restarts, re-dos and un-dos... very very expensive halts, as this box was a server for all "EDI" applications.

    We started digging around, and found that although the server in question was running proceeses using a total of 5-6 GB (just adding up what we saw in Task Manager), the system was defined with a "max swap file size" of only 4 Gb.

    Since we were both in over our heads at this point, we asked the 'systems' guy to take a look ... he reset the swap file to allow Windows to manage the swap file size.

    No more errors since August.

    Just a little something to check out next time you get "weird, impossible" errors like this.

    MCM

    Leave a comment:


  • Paul Purvis
    replied
    thanks for those replies,
    i have not had access to the internet over the last week
    paul

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    if you had done a lot of work in the days of 640Kb max.).

    >> (Later got a 16kB extension pack)

    Wow 640 Kb !

    I started programming on a "pre-PC" machine that had 16 Kb

    I even used a machine with 8 Kb once

    And some of even started with computers only had 6 bits to a byte

    You were spoiled. I started on a ZX81 with 1k RAM...

    ...
    Mine is smaller than yours! Nyahda nyahda nyah da!

    Leave a comment:


  • Nick Luick
    replied
    Sorry, deleted content not appropiate for thread
    Last edited by Nick Luick; 5 Feb 2008, 01:42 AM. Reason: Wrong for forum thread

    Leave a comment:


  • John Petty
    replied
    And some of even started with computers only had 6 bits to a byte

    Leave a comment:


  • Mel Bishop
    replied
    Originally posted by Peter Lameijn View Post
    >> (Later got a 16kB extension pack)
    Bet it cost you about 6 months pay or somewhere thereabouts.

    Leave a comment:


  • Peter Lameijn
    replied
    >> I even used a machine with 8 Kb once

    You were spoiled. I started on a ZX81 with 1k RAM...
    (Later got a 16kB extension pack)

    Leave a comment:


  • Mark Strickland
    replied
    640 Kb ???

    Wow 640 Kb !

    I started programming on a "pre-PC" machine that had 16 Kb
    I even used a machine with 8 Kb once and it had a nice FORTRAN compiler on it. Of course it did not waste any RAM on a GUI since you fed it punch cards.

    The next generation of programmers will probably wonder what to do when they cannot allocate that terra-byte of RAM as an array.

    But to be serious -- we should learn from the past and balance previous constraints that required more design elegance with better resource availability today -or- in pragmatic terms: "Just because you have RAM does not mean it is or is not the best solution. Examine the problem from many angles, understand your constraints and requirements, then find a good solution."

    Leave a comment:

Working...
X