Skip to content

Commit 0378f62

Browse files
committed
Add notes on memory usage in readme
1 parent e7a0350 commit 0378f62

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,25 @@ Finally, you might want to get some information about the location that correspo
113113
For more information about the other functionality available from the library, look in the unit tests or in the original
114114
[libphonenumber project](http://code.google.com/p/libphonenumber/).
115115

116+
Memory Usage
117+
------------
118+
119+
The library includes a lot of metadata, giving a significant memory overhead. This metadata is loaded on-demand so that
120+
the memory footprint of applications that only use a subset of the library functionality is not adversely affected.
121+
122+
In particular:
123+
124+
* The geocoding metadata (which makes up around 75% of the total memory footprint) is only loaded on the first use of
125+
one of the geocoding functions (`description_for_number`, `description_for_valid_number`,
126+
`area_description_for_number` and `country_name_for_number`).
127+
* The normal metadata for each region is only loaded on the first time that metadata for that region is needed.
128+
129+
If you need to ensure that the metadata memory use is accounted for at start of day (i.e. that a subsequent on-demand
130+
load of metadata will not cause memory exhaustion):
131+
132+
* Force-load the geocoding metadata by invoking `import phonenumbers.geocoder`.
133+
* Force-load the normal metadata by calling `phonenumbers.PhoneMetadata.load_all()`.
134+
116135
Project Layout
117136
--------------
118137
* The `python/` directory holds the Python code.

0 commit comments

Comments
 (0)