Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation from source code
Components
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
About The Best Formula In The World
Architecture details
Benchmarks
Books
By Reference Argument Passing
Compatibility between versions
Creating And Using Libraries
Database Datatype Mapping
Database Request Quoting
Date & time management
Dates and calendars
DBus and Gambas
Differences Between Shell And Exec
Differences From Visual Basic
Distributions & Operating Systems
Drag & Drop
DrawingArea Internal Behaviour
External functions datatype mapping
Frequently Asked Questions
Gambas Farm Server Protocol
Gambas Mailing List Netiquette
Gambas Markdown Syntax
Gambas Naming Conventions
Gambas Object Model
Gambas Scripting
Gambas Server Pages
Gambas Unit Testing
Gambas Wiki Markup Syntax
Getting Started With Gambas
Hall Of Fame
Housekeeping, cleaning up
Image Management In Gambas
Including Help Comments in Source Code
Installation from binary packages
Interpreter limits
Introduction
Just In Time Compiler
Just In Time Compiler (old version)
License
Localisation and Internationalization
Mailing Lists & Forums
Naming Conventions
Network Programming
ODBC Component Documentation
PCRE Pattern Syntax
Porting from Gambas 2 to Gambas 3
Previous News
Project Directory Structure
Release Notes
Reporting a problem, a bug or a crash
Rich Text Syntax
Screenshots
Text highlighting definition file syntax
The Program has stopped unexpectedly by raising signal #11
Variable Naming Convention
WebPage Syntax
Web site home page
What Is Gambas?
Window & Form Management
Window Activation & Deactivation
Window Life Cycle
XML APIs
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

Housekeeping, cleaning up

Residual temporary process folders

A little pre-text..

When you run a gambas program various process folders are (or can be) created related to the process ID. (Application.Handle) So for example if you program runs and has the process ID of 2345 then the following happens...

  • linux creates a main process folder in /proc/

/proc/2345
  • gambas creates a temp folder (accessed in your application using the Temp() command)

/tmp/gambas.1000/2345
  • gambas JIT (if enabled) creates a temp folder.

/run/user/1000/gambas/2345
  • gtk3 may or not make a folder (depending on components used)

$HOME/.cache/org.gambas.2345
  • webkit may or may not make a folder.

$HOME/.local/share/org.gambas.2345

When your application closes all these folders should automatically delete as the application/libraries clean up.

There are however many things that can stop the cleanup !

  • If the program crashes.

  • If the program is terminated "Killed"

  • The program hard exits when the system shuts down or logs out while it's running.

This includes background programs launched at startup that remain running all the time, they are killed when the system shuts down so may not clean up.
If the cleanup process does not happen then the above mentioned folders could be left behind.
Mostly it will not matter.
  • The folder in /proc/ is removed by the system.

  • The folder in /tmp/gambas.1000/ will clear at reboot.

  • The folder in /run/user/1000/gambas/ will clear at reboot.

If however, your program has made temporary folders in the $HOME folder and does not exit normally then they will not be removed and will accumulate on your drive.

Sadly this cannot really be helped :(

Note: The temporary folders made in home are from GTK+ usage, if your programs uses QT not GTK then these folders are not created)

A simple function like this can be used to keep your disk clean.

It scans the home folder for temporary gambas folders that do not have a matching active process folder ID in /proc/ and deletes them.


Public Sub RemoveObsoleteDirs()

  For Each sLocation As String In [User.Home &/ ".cache", User.Home &/ ".local/share"]

    For Each sDir As String In Dir(sLocation, "org.gambas.*", gb.Directory)  ' List all org.gambas.* folders in sLocation
      If Not Exist("/proc" &/ File.Ext(sDir)) Then Shell "rm -rf " & sLocation &/ sDir Wait
    Next

  Next

End