Announcement

Collapse
No announcement yet.

Something to look out for

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

  • Something to look out for

    Jose',
    I recently switched my app over to CWindow.inc with %USEWEBBROWSER = 1 from the traditional method of Win32Api.inc and noticed my app crashing when calls were made to simple declared threads.

    The app had a maximum of 32 threads initially. 5 were continuous. The rest were temporary. I had to eliminate 2 of the temporary threads to keep my program from crashing on those threads. I am not sure what the limit is for threads allowed per application. Any idea about this situation?

    Thanks

  • #2
    I found this in my SDK-on-a-disk... ..


    The number of threads a process can create is limited by the available virtual memory. By default, every thread has one megabyte of stack space. Therefore, you can create at most 2028 threads. If you reduce the default stack size, you can create more threads. However, your application will have better performance if you create one thread per processor and build queues of requests for which the application maintains the context information. A thread would process all requests in a queue before processing requests in the next queue.
    .. so maybe you want to try increasing the stack size? I doubt that will do anything since stack is allocated dynamically but it's a cheap try.

    I 'assume' you have inspected the error codes on the thread creation calls?
    Michael Mattias
    Tal Systems Inc.
    Racine WI USA
    mmattias@talsystems.com
    http://www.talsystems.com

    Comment


    • #3
      Hi Mike,
      Thanks

      Ah no I didn't check that but I did check Task Manager which did not indicate there was any problem with the program as in "The app is running normal". Weird Huh?

      The only change was the type of includes I was using and whether %USEWEBBROWSER was enabled. I thought there might be a naming conflict with the new includes so I renamed my threads but it did not change the offending behavior.
      %USEWEBBROWSER = 1 was the nail to the coffin.

      I was thinking that possibly %USEWEBBROWSER = 1 was creating threads too. That's why I was hoping Jose' would chime in on this.

      Today I am in the process of eliminating all temporary threads.

      Note: I do not enable %UNICODE.

      Comment


      • #4
        Ah no I didn't check that but I did check Task Manager which did not indicate there was any problem with the program as in "The app is running normal". Weird Huh?
        No, not "weird." Not weird at all.

        How the heck would Windows' Task Manager even have a clue as to what "the app is running normal" means?

        Windows' Task Manager is not a replacement for programmer's code to check return codes and errors!


        And part Deux:
        was thinking that possibly %USEWEBBROWSER = 1 was creating threads too
        The only lines of source code which create additional threads of execution are executable lines such as "CALL CreateThread (..._..)" (API call) or "THREAD CREATE" (PB statement) ... EXCEPT:

        Some WinAPI calls internally create additional threads of execution. For example, ShFileOperation() will create additional TOEs under SOME conditions.

        The definition of an equate does not execute anything, although it may be used in a conditional compilation statement (#IF .. #ELSE ... #ENDIF) which inclusion or omission causes a thread-creating source code line to be included.

        MCM
        Michael Mattias
        Tal Systems Inc.
        Racine WI USA
        mmattias@talsystems.com
        http://www.talsystems.com

        Comment


        • #5
          What %USEWEBBROWSER = 1 does is to include exdisp.inc, mshtml.inc, mshtmhst.inc and olecon.inc. It does not execute any code and it does not create any thread. It simply allows to use an Ole container to embed an instance of the WebBrowser control and to use the html interfaces and some wrapper functions. You will have to call the AddWebBrowserControl method to get any code executed. If the WebBrowser control creates or not its own threads, I don't know.
          Forum: http://www.jose.it-berater.org/smfforum/index.php

          Comment


          • #6
            Yes I know the appropriate techniques are the key to divulging the root cause of the problem. Weird as in not what I expected.

            In the past Task Manager would indicate in wait chain something entirely different. "Waiting on thread to complete." %USEWEBBROWSER has a bearing on what the includes do.

            These were my original includes:

            Code:
            OPTION EXPLICIT
            '#DEBUG DISPLAY ON
            
            #INCLUDE ONCE "WIN32API.INC"
            #INCLUDE ONCE "COMMCTRL.INC"
            #INCLUDE ONCE "COMDLG32.INC"
            #INCLUDE ONCE "RICHEDIT.INC"
            #INCLUDE ONCE "WSAGETLASTERROR.INC"
            #INCLUDE ONCE "mciavi.inc"
            #INCLUDE ONCE "digitalv.inc"
            #INCLUDE ONCE "SAPI.inc"           'used for SAPI
            #INCLUDE ONCE "SendInput.inc"
            #INCLUDE ONCE "LMCons.inc"
            #INCLUDE ONCE "mmdeviceapi.inc"    'used for WASAPI Windows Audio Session API
            #INCLUDE ONCE "devpkey.inc"        'used for WASAPI
            #INCLUDE ONCE "propsys.inc"        'used for WASAPI
            #INCLUDE ONCE "propvarutil.inc"    'used for WASAPI
            #INCLUDE ONCE "endpointvolume.inc" 'used for WASAPI
            #INCLUDE ONCE "LmwkSta.inc"
            #INCLUDE ONCE "IpHlpApi.inc"
            #INCLUDE ONCE "WinIoCtl.inc"
            #INCLUDE ONCE "Windows.inc"
            #INCLUDE ONCE "UrlMon.inc"
            #INCLUDE ONCE "AfxShell.inc"
            #INCLUDE ONCE "WinINET.inc"        'for weather
            #INCLUDE ONCE "tlhelp32.inc"
            #INCLUDE ONCE "PBForms.inc" ' comes with PBWIN - very useful
            These are my current includes:

            Code:
            #INCLUDE ONCE "CWINDOW.INC"         ' // CWindow class
            
            #INCLUDE ONCE "SENDINPUT.INC"       ' local file
            #INCLUDE ONCE "WSAGETLASTERROR.INC" ' local file
            #INCLUDE ONCE "AFXDLG.INC"          '
            #INCLUDE ONCE "AFXSHELL.INC"        '
            #INCLUDE ONCE "ANIMATECTRL.INC"     '
            #INCLUDE ONCE "BUTTONCTRL.INC"      '
            #INCLUDE ONCE "COMBOBOXCTRL.INC"    '
            #INCLUDE ONCE "COMBOBOXEXCTRL.INC"  '
            #INCLUDE ONCE "COMCAT.INC"          '
            #INCLUDE ONCE "COMDLG32.INC"        '
            #INCLUDE ONCE "COMMDLG.INC"         '
            #INCLUDE ONCE "CRTDEFS.INC"         '
            #INCLUDE ONCE "DATETIMECTRL.INC"    '
            #INCLUDE ONCE "DEVICETOPOLOGY.INC"  '
            #INCLUDE ONCE "DEVPKEY.INC"         '    'used for WASAPI
            #INCLUDE ONCE "DEVPROPDEF.INC"      '
            #INCLUDE ONCE "DIGITALV.INC"        '
            #INCLUDE ONCE "EDITCTRL.INC"        '
            #INCLUDE ONCE "ENDPOINTVOLUME.INC"  '    'used for WASAPI
            #INCLUDE ONCE "EXCPT.INC"           '
            #INCLUDE ONCE "HEADERCTRL.INC"      '
            #INCLUDE ONCE "HOTKEYCTRL.INC"      '
            #INCLUDE ONCE "IFDEF.INC"           '
            #INCLUDE ONCE "IFMIB.INC"           '
            #INCLUDE ONCE "IN6ADDR.INC"         '
            #INCLUDE ONCE "IPADDRESSCTRL.INC"   '
            #INCLUDE ONCE "IPEXPORT.INC"        '
            #INCLUDE ONCE "IPHLPAPI.INC"        '    'used for MAC and Internet connection
            #INCLUDE ONCE "IPIFCONS.INC"        '
            #INCLUDE ONCE "IPMIB.INC"           '
            #INCLUDE ONCE "IPRTRMIB.INC"        '
            #INCLUDE ONCE "IPTYPES.INC"         '
            #INCLUDE ONCE "LISTBOXCTRL.INC"     '
            #INCLUDE ONCE "LISTVIEWCTRL.INC"    '
            #INCLUDE ONCE "LMCONS.INC"          '
            #INCLUDE ONCE "LMUSEFLG.INC"        '
            #INCLUDE ONCE "LMWKSTA.INC"         '
            #INCLUDE ONCE "MCIAVI.INC"          '
            #INCLUDE ONCE "MMDEVICEAPI.INC"     '    'used for WASAPI Windows Audio Session API
            #INCLUDE ONCE "MONTHCALCTRL.INC"    '
            #INCLUDE ONCE "MPRAPI.INC"          '
            #INCLUDE ONCE "MPRERROR.INC"        '
            #INCLUDE ONCE "NETIOAPI.INC"        '
            #INCLUDE ONCE "NLDEF.INC"           '
            #INCLUDE ONCE "NTDDNDIS.INC"        '
            #INCLUDE ONCE "OBJECTARRAY.INC"     '
            #INCLUDE ONCE "PAGERCTRL.INC"       '
            #INCLUDE ONCE "PCIPROP.INC"         '
            #INCLUDE ONCE "PROGRESSBARCTRL.INC" '
            #INCLUDE ONCE "PROPAPI.INC"         '
            #INCLUDE ONCE "PROPSYS.INC"         '    'used for WASAPI
            #INCLUDE ONCE "PROPVARUTIL.INC"     '    'used for WASAPI
            #INCLUDE ONCE "PRSHT.INC"           '
            #INCLUDE ONCE "RAS.INC"             '
            #INCLUDE ONCE "RASERROR.INC"        '
            #INCLUDE ONCE "REBARCTRL.INC"       '
            #INCLUDE ONCE "RICHEDIT.INC"        '
            #INCLUDE ONCE "RICHEDITCTRL.INC"    '
            #INCLUDE ONCE "SAPI.INC"            '    'used for SAPI
            #INCLUDE ONCE "SCROLLBARCTRL.INC"   '
            #INCLUDE ONCE "SHERRORS.INC"        '
            #INCLUDE ONCE "SHLOBJ.INC"          '
            #INCLUDE ONCE "SHLWAPI.INC"         '
            #INCLUDE ONCE "SHOBJIDL.INC"        '
            #INCLUDE ONCE "SPERROR.INC"         '
            #INCLUDE ONCE "STATICCTRL.INC"      '
            #INCLUDE ONCE "STATUSBARCTRL.INC"   '
            #INCLUDE ONCE "STRUCTUREDQUERYCONDITION.INC"      '
            #INCLUDE ONCE "SYSLINKCTRL.INC"     '
            #INCLUDE ONCE "TABCTRL.INC"         '
            #INCLUDE ONCE "TASKDIALOGCTRL.INC"  '
            #INCLUDE ONCE "TCPESTATS.INC"       '
            #INCLUDE ONCE "TCPMIB.INC"          '
            #INCLUDE ONCE "TLHELP32.INC"        '
            #INCLUDE ONCE "TOOLBARCTRL.INC"     '
            #INCLUDE ONCE "TRACKBARCTRL.INC"    '
            #INCLUDE ONCE "TREEVIEWCTRL.INC"    '
            #INCLUDE ONCE "UDPMIB.INC"          '
            #INCLUDE ONCE "UPDOWNCTRL.INC"      '
            #INCLUDE ONCE "UXTHEME.INC"         '
            #INCLUDE ONCE "VSSTYLE.INC"         '
            #INCLUDE ONCE "VSSYM32.INC"         '
            #INCLUDE ONCE "WINDOT11.INC"        '
            #INCLUDE ONCE "WINDOWSX.INC"        '
            #INCLUDE ONCE "WININET.INC"         '    'for weather
            #INCLUDE ONCE "WLANTYPES.INC"       '
            #INCLUDE ONCE "WS2IPDEF.INC"        '
            You will have to call the AddWebBrowserControl method to get any code executed. If the WebBrowser control creates or not its own threads, I don't know.
            Good to know.
            Thank you Jose'

            Comment


            • #7
              One method I tried was to load all CWINDOW.INC files individually with %USEWEBBROWSER = 0 and added in
              exdisp.inc, mshtml.inc, mshtmhst.inc and olecon.inc as well.
              The crashing behavior didn't happen as long as OLECON was not included. Any Ideas about that?

              Comment


              • #8
                No, it doesn't make any sense to me. It must be something else.
                Forum: http://www.jose.it-berater.org/smfforum/index.php

                Comment


                • #9
                  Yeah. I know, it doesn't make sense to me either. That's ok
                  Removing some temporary threads seems to have fixed the problem for now. Will let you know if its ugly head pops back up again. Keeping my fingers crossed.

                  Thanks

                  Comment

                  Working...
                  X