home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / ARQS_ZIP / BV0699.ZIP / BV0699.TXT
Encoding:
Text File  |  1992-11-09  |  7.1 KB  |  129 lines

  1. ======================================================================
  2.   Microsoft(R) Product Support Services Application Note (Text File)
  3.              BV0699: MEMORY MANAGEMENT QUESTIONS & ANSWERS
  4. ======================================================================
  5.                                                   Revision Date: 11/92
  6.                                                       No Disk Included
  7.  
  8. The following information applies to Microsoft Visual Basic(TM) for
  9. Windows(TM) versions 1.0 and 2.0.
  10.  
  11.  --------------------------------------------------------------------
  12. | INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY    |
  13. | ACCOMPANY THIS DOCUMENT (collectively referred to as an            |
  14. | Application Note) IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY      |
  15. | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO    |
  16. | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A     |
  17. | PARTICULAR PURPOSE. The user assumes the entire risk as to the     |
  18. | accuracy and the use of this Application Note. This Application    |
  19. | Note may be copied and distributed subject to the following        |
  20. | conditions: 1) All text must be copied without modification and    |
  21. | all pages must be included; 2) If software is included, all files  |
  22. | on the disk(s) must be copied without modification [the MS-DOS(R)  |
  23. | utility DISKCOPY is appropriate for this purpose]; 3) All          |
  24. | components of this Application Note must be distributed together;  |
  25. | and 4) This Application Note may not be distributed for profit.    |
  26. |                                                                    |
  27. | Copyright 1992 Microsoft Corporation. All Rights Reserved.         |
  28. | Microsoft and MS-DOS are registered trademarks and QuickBasic,     |
  29. | Visual Basic, and Windows are trademarks of Microsoft Corporation. |
  30.  --------------------------------------------------------------------
  31.  
  32. 1. Q. What should I do when I receive the error message "Out of
  33.       memory" at design time or at run time?
  34.  
  35.    A. The "Out of memory" error message does not necessarily indicate
  36.       that you have run out of conventional memory. This error message
  37.       occurs most commonly when you have exhausted the system
  38.       resources. To determine if a lack of system resources has caused
  39.       this problem, check the percentage of free system resources in
  40.       the About Program Manager dialog box. (To view this dialog box,
  41.       choose About Program Manager from the Help menu in Program
  42.       Manager.) If the percentage of system resources available is less
  43.       than 10 percent, you have probably exhausted the system
  44.       resources.
  45.    
  46.       Because each loaded form and control consumes system resources,
  47.       you can conserve system resources by limiting the number of forms
  48.       and controls that you load. Using the Load statement, load only
  49.       the forms that are necessary. When a form is no longer needed,
  50.       unload it with the Unload statement to free system resources
  51.       associated with that form. Simply hiding the form with the Hide
  52.       method does not free system resources.
  53.    
  54.       If you are using Microsoft Visual Basic version 2.0 for Windows,
  55.       you can conserve system resources by using the graphical
  56.       controls, such as the image, shape, and line controls. The label
  57.       control is also a graphical control in version 2.0. Because these
  58.       controls paint themselves directly onto the form, they use
  59.       significantly fewer system resources than nongraphical controls.
  60.       For example, it is recommended that you use an image control in
  61.       place of a picture control wherever possible. For more
  62.       information on how to optimize resource usage, please refer to
  63.       Chapter 11 of the version 2.0 "Programmer's Guide."
  64.  
  65.       The "Out of memory" error message can also occur if you have run
  66.       out of memory in a particular 64-kilobyte (64K) code or data
  67.       segment. Appendix D of the Visual Basic 2.0 "Programmer's Guide"
  68.       outlines various memory limits related to code and data segments.
  69.  
  70.       Because Visual Basic 2.0 supports arrays greater than 64K up to
  71.       the limit of total available memory, it is possible to run out of
  72.       total memory. The amount of total memory available is reported in
  73.       the About Program Manager dialog box.
  74.  
  75. 2. Q. What is the maximum string size in Microsoft Visual Basic
  76.       for Windows?
  77.  
  78.    A. Visual Basic allows strings up to 64K. This is different from
  79.       Microsoft QuickBasic(TM) and the Microsoft Basic Professional
  80.       Development System, which allow strings up to 32K only. For more
  81.       information on code and data limits, please refer to Appendix D
  82.       of the Visual Basic version 2.0 "Programmer's Guide."
  83.  
  84. 3. Q. I am using version 1.0 of Microsoft Visual Basic for
  85.       Windows. When I try to dimension an array larger than 64K, I
  86.       receive the error message "Subscript out of range." What is
  87.       causing this problem?
  88.  
  89.    A. Version 1.0 of Visual Basic does not contain built-in support for
  90.       huge arrays (that is, arrays larger than 64K). Therefore, if you
  91.       try to dimension an array larger than 64K, you receive the
  92.       "Subscript out of range" error message. The maximum array size
  93.       for any array type is 64K; however, each form and/or module can
  94.       declare as many 64K arrays as there is memory available to
  95.       handle. This 64K array limit no longer exists in version 2.0 of
  96.       Visual Basic, which supports huge arrays of any type.
  97.  
  98. 4. Q. When I try to declare an array within a user-defined type in
  99.       version 1.0 of Microsoft Visual Basic for Windows, I receive the
  100.       error message "feature unavailable." What is causing this error?
  101.  
  102.    A. Visual Basic version 1.0 does not support arrays within user-
  103.       defined types. To get support for arrays within user-defined
  104.       types, you must use Visual Basic version 2.0.
  105.  
  106. 5. Q. Where can I find more information about Microsoft Visual
  107.       Basic for Windows data types?
  108.  
  109.    A. Information on Visual Basic data types can be found in Chapter 7
  110.       of the Visual Basic version 2.0 "Programmer's Guide" and on pages
  111.       83 and 84 of Chapter 9 in the Visual Basic version 1.0
  112.       "Programmer's Guide."
  113.  
  114.       Please note that the default type for Visual Basic 2.0 is Variant
  115.       and several Visual Basic functions now return the Variant data
  116.       type instead of a numeric data type, such as Single or Double. In
  117.       version 1.0, the default data type is Single. This change may
  118.       impact your existing code written using Visual Basic version 1.0.
  119.       For example, if you are printing the return value of the
  120.       SerialDate function, the result will be a formatted date string
  121.       instead of a serial number. To change the default type, you must
  122.       include a Def<type> statement in the general declaration section
  123.       of each form and module. For example, if you want to set the
  124.       default type to Single, which is the default type for version
  125.       1.0, use the statement DefSNG and specify the letter range A
  126.       through Z in all forms and modules for the project.
  127.  
  128.  
  129.