Unloading a lisp

Discussion in 'AutoCAD' started by MarcelGoulet, May 28, 2004.

  1. MarcelGoulet

    MarcelGoulet Guest

    Hi,

    Is it possible to unload a lisp from memory ?
    if yes, how ?

    Thanks
     
    MarcelGoulet, May 28, 2004
    #1
  2. MarcelGoulet

    Jürg Menzi Guest

    MarcelGoulet

    Not really, but you can set all defun's to nil and call (gc).

    Cheers
     
    Jürg Menzi, May 28, 2004
    #2
  3. MarcelGoulet

    MarcelGoulet Guest

    How do I set a defun to nil ?
    and what is (gc) ?
     
    MarcelGoulet, May 28, 2004
    #3
  4. MarcelGoulet

    Doug Broad Guest

    (defun yourfunction () .........)

    (setq yourfunction nil)

    gc is a function to force "garbage collection",
    a recovery process.

    I typically do not remove the functions. Each
    time a drawing is closed, the functions associated
    with that namespace are deleted.

    Regards,
    Doug
     
    Doug Broad, May 28, 2004
    #4
  5. MarcelGoulet

    Jürg Menzi Guest

    Marcel
    Assume a function like this:
    (defun C:MyTest ()
    (princ "\nTest...")
    (princ)
    )

    Command: MyTest
    Test...

    Command: (setq C:MyTest nil)

    Command: MyTest
    ; Error: no function definition: C:MYTEST

    (gc) Forces a garbage collection, witch frees up unused nodes

    Cheers
     
    Jürg Menzi, May 28, 2004
    #5
  6. MarcelGoulet

    MarcelGoulet Guest

    Is there a way to obtain all loaded fonctions?
     
    MarcelGoulet, May 28, 2004
    #6
  7. MarcelGoulet

    MarcelGoulet Guest

    I found a way to obtain a list of all my functions.

    After that, I use
    (foreach FUNCTION FUNCTIONS_LIST
    (setq FUNCTION nil)
    )
    But it doesn't work because the function names are strings and it should not be a string.

    How can I convert it to not be a string ?
     
    MarcelGoulet, May 28, 2004
    #7
  8. MarcelGoulet

    Jürg Menzi Guest

    Marcel

    From AutoCAD Developer Help:

    atoms-family
    Returns a list of the currently defined symbols
    (atoms-family format [symlist])

    Arguments
    format
    An integer value of 0 or 1 that determines the format in which atoms-family
    returns the symbol names:
    0 Return the symbol names as a list
    1 Return the symbol names as a list of strings
    symlist :
    A list of strings that specify the symbol names you want atoms-family to
    search for.

    Return Values
    A list of symbols. If you specify symlist, then atoms-family returns the
    specified symbols that are currently defined, and returns nil for those
    symbols that are not defined.

    Examples
    Command: (atoms-family 0)
    (BNS_PRE_SEL FITSTR2LEN C:AI_SPHERE ALERT DEFUN C:BEXTEND REM_GROUP
    B_RESTORE_SYSVARS BNS_CMD_EXIT LISPED FNSPLITL...

    The following code verifies that the symbols CAR, CDR, and XYZ are defined, and
    returns the list as strings:
    Command: (atoms-family 1 '("CAR" "CDR" "XYZ"))
    ("CAR" "CDR" nil)
    The return value shows that the symbol XYZ is not defined.

    Cheers
     
    Jürg Menzi, May 28, 2004
    #8
  9. MarcelGoulet

    Jürg Menzi Guest

    Marcel
    (set (read FUNCTION) nil)

    Cheers
     
    Jürg Menzi, May 28, 2004
    #9
  10. (setq c:mylisp nil)
    or
    (setq mylisp nil)

    (gc) - Forces a garbage collection, which frees up unused memory - re: the
    documentation.
     
    Martin Schmid, May 28, 2004
    #10
  11. MarcelGoulet

    Rudy Tovar Guest

    As mentioned the disable a function from memory it would be as mentioned.

    (setq function1 nil)

    And as mentioned (gc) is garbage collection.

    Autocad has a reserved node space for autolisp functions, which may greater
    or less than a few 1000, depending on defined functions and floating
    variables. Which is why you must make sure to control the amount of lisp
    files that are being loaded.

    Alternatively you may create VLX files that are external function so that
    you don't overload autocads node space, if memory serves right.

    Occationally you may have problems opening large files, or even recovering
    files do too very little node space, in which case you may perform a (repeat
    10 (gc)) to free up some memory.
    --

    AUTODESK
    Authorized Developer
    http://www.Cadentity.com
    MASi
     
    Rudy Tovar, May 28, 2004
    #11
  12. MarcelGoulet

    Rudy Tovar Guest

    I've got remember to proof read and spell check when sending...
     
    Rudy Tovar, May 28, 2004
    #12
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.