@cython.final @cython.internal cdef class _MemDebug: """Debugging support for the memory allocation in libxml2. """ def bytes_used(self): """bytes_used(self) Returns the total amount of memory (in bytes) currently used by libxml2. Note that libxml2 constrains this value to a C int, which limits the accuracy on 64 bit systems. """ return tree.xmlMemUsed() def blocks_used(self): """blocks_used(self) Returns the total number of memory blocks currently allocated by libxml2. Note that libxml2 constrains this value to a C int, which limits the accuracy on 64 bit systems. """ return tree.xmlMemBlocks() def dict_size(self): """dict_size(self) Returns the current size of the global name dictionary used by libxml2 for the current thread. Each thread has its own dictionary. """ c_dict = __GLOBAL_PARSER_CONTEXT._getThreadDict(NULL) if c_dict is NULL: raise MemoryError() return tree.xmlDictSize(c_dict) def dump(self, output_file=None, byte_count=None): """dump(self, output_file=None, byte_count=None) Dumps the current memory blocks allocated by libxml2 to a file. The optional parameter 'output_file' specifies the file path. It defaults to the file ".memorylist" in the current directory. The optional parameter 'byte_count' limits the number of bytes in the dump. Note that this parameter is ignored when lxml is compiled against a libxml2 version before 2.7.0. """ cdef Py_ssize_t c_count if output_file is None: output_file = b'.memorylist' elif isinstance(output_file, unicode): output_file.encode(sys.getfilesystemencoding()) f = stdio.fopen(output_file, "w") if f is NULL: raise IOError(f"Failed to create file {output_file.decode(sys.getfilesystemencoding())}") try: if byte_count is None: tree.xmlMemDisplay(f) else: c_count = byte_count tree.xmlMemDisplayLast(f, c_count) finally: stdio.fclose(f) def show(self, output_file=None, block_count=None): """show(self, output_file=None, block_count=None) Dumps the current memory blocks allocated by libxml2 to a file. The output file format is suitable for line diffing. The optional parameter 'output_file' specifies the file path. It defaults to the file ".memorydump" in the current directory. The optional parameter 'block_count' limits the number of blocks in the dump. """ if output_file is None: output_file = b'.memorydump' elif isinstance(output_file, unicode): output_file.encode(sys.getfilesystemencoding()) f = stdio.fopen(output_file, "w") if f is NULL: raise IOError(f"Failed to create file {output_file.decode(sys.getfilesystemencoding())}") try: tree.xmlMemShow(f, block_count if block_count is not None else tree.xmlMemBlocks()) finally: stdio.fclose(f) memory_debugger = _MemDebug()
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
__pycache__ | Folder | 0755 |
|
|
html | Folder | 0755 |
|
|
includes | Folder | 0755 |
|
|
isoschematron | Folder | 0755 |
|
|
ElementInclude.py | File | 8.36 KB | 0644 |
|
__init__.py | File | 575 B | 0644 |
|
_elementpath.cpython-311-x86_64-linux-gnu.so | File | 419.42 KB | 0755 |
|
_elementpath.py | File | 10.49 KB | 0644 |
|
apihelpers.pxi | File | 62.94 KB | 0644 |
|
builder.cpython-311-x86_64-linux-gnu.so | File | 222.23 KB | 0755 |
|
builder.py | File | 7.96 KB | 0644 |
|
classlookup.pxi | File | 21.94 KB | 0644 |
|
cleanup.pxi | File | 8.26 KB | 0644 |
|
cssselect.py | File | 3.29 KB | 0644 |
|
debug.pxi | File | 3.21 KB | 0644 |
|
docloader.pxi | File | 5.65 KB | 0644 |
|
doctestcompare.py | File | 17.91 KB | 0644 |
|
dtd.pxi | File | 14.86 KB | 0644 |
|
etree.cpython-311-x86_64-linux-gnu.so | File | 8.46 MB | 0755 |
|
etree.h | File | 8.37 KB | 0644 |
|
etree.pyx | File | 129.31 KB | 0644 |
|
etree_api.h | File | 17.06 KB | 0644 |
|
extensions.pxi | File | 32.46 KB | 0644 |
|
iterparse.pxi | File | 16.22 KB | 0644 |
|
lxml.etree.h | File | 8.37 KB | 0644 |
|
lxml.etree_api.h | File | 17.06 KB | 0644 |
|
nsclasses.pxi | File | 8.93 KB | 0644 |
|
objectify.cpython-311-x86_64-linux-gnu.so | File | 4.25 MB | 0755 |
|
objectify.pyx | File | 75.29 KB | 0644 |
|
objectpath.pxi | File | 11.21 KB | 0644 |
|
parser.pxi | File | 76.41 KB | 0644 |
|
parsertarget.pxi | File | 6.7 KB | 0644 |
|
proxy.pxi | File | 23.01 KB | 0644 |
|
public-api.pxi | File | 6.5 KB | 0644 |
|
pyclasslookup.py | File | 92 B | 0644 |
|
readonlytree.pxi | File | 18.6 KB | 0644 |
|
relaxng.pxi | File | 5.94 KB | 0644 |
|
sax.cpython-311-x86_64-linux-gnu.so | File | 366.73 KB | 0755 |
|
sax.py | File | 9.18 KB | 0644 |
|
saxparser.pxi | File | 31.78 KB | 0644 |
|
schematron.pxi | File | 5.65 KB | 0644 |
|
serializer.pxi | File | 66.41 KB | 0644 |
|
usedoctest.py | File | 230 B | 0644 |
|
xinclude.pxi | File | 2.4 KB | 0644 |
|
xmlerror.pxi | File | 48.37 KB | 0644 |
|
xmlid.pxi | File | 5.92 KB | 0644 |
|
xmlschema.pxi | File | 7.89 KB | 0644 |
|
xpath.pxi | File | 19.11 KB | 0644 |
|
xslt.pxi | File | 35.83 KB | 0644 |
|
xsltext.pxi | File | 10.83 KB | 0644 |
|