Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

virtual_memory on FreeBSD #997

Closed
iblislin opened this issue Mar 23, 2017 · 10 comments
Closed

virtual_memory on FreeBSD #997

iblislin opened this issue Mar 23, 2017 · 10 comments
Labels

Comments

@iblislin
Copy link

I got this

In [9]: psutil.virtual_memory()
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-9-5ca35f683e59> in <module>()
----> 1 psutil.virtual_memory()

/usr/home/iblis/venv/concurrent_ap/lib/python3.6/site-packages/psutil/__init__.py in virtual_memory()
   1983     """
   1984     global _TOTAL_PHYMEM
-> 1985     ret = _psplatform.virtual_memory()
   1986     # cached for later use in Process.memory_percent()
   1987     _TOTAL_PHYMEM = ret.total

/usr/home/iblis/venv/concurrent_ap/lib/python3.6/site-packages/psutil/_psbsd.py in virtual_memory()
    177 def virtual_memory():
    178     """System virtual memory as a namedtuple."""
--> 179     mem = cext.virtual_mem()
    180     total, free, active, inactive, wired, cached, buffers, shared = mem
    181     if NETBSD:

FileNotFoundError: [Errno 2] No such file or directory
@iblislin
Copy link
Author

In [7]: platform.version()
Out[7]: 'FreeBSD 12.0-CURRENT #4 r309367: Mon Dec 12 11:10:09 CST 2016     root@abeing:/usr/obj/usr/src/sys/GENERIC'

@giampaolo
Copy link
Owner

Please try the followings in your shell:

sysctl hw.physmem
sysctl vm.stats.vm.v_active_count
sysctl vm.stats.vm.v_inactive_count
sysctl vm.stats.vm.v_wire_count
sysctl vm.stats.vm.v_cache_count
sysctl vm.stats.vm.v_free_count
sysctl vfs.bufspace

I expect one of these to fail.

@iblislin
Copy link
Author

only vm.stats.vm.v_cache_count failed

└─[iblis@abeing]% sysctl vm.stats.vm.v_cache_count
sysctl: unknown oid 'vm.stats.vm.v_cache_count'

@iblislin
Copy link
Author

giampaolo added a commit that referenced this issue Mar 23, 2017
@giampaolo
Copy link
Owner

OK I should have fixed it. Could you give it a try by using latest GIT version?

@iblislin
Copy link
Author

I found this commit remove it: https://svnweb.freebsd.org/base?view=revision&revision=309017

@giampaolo
Copy link
Owner

giampaolo commented Mar 23, 2017

Nice find. It looks like they removed it 'cause the value was always set to 0 since god knows when. It probably makes sense to remove it from psutil as well. I don't think it's gonna be a big deal in terms of backward compatibility.

@iblislin
Copy link
Author

@giampaolo The patch works fine!

@giampaolo
Copy link
Owner

Actually, since cached memory may be correctly calculated on NetBSD and OpenBSD, I think it's better to leave it in place and set it to 0 if it fails.

@iblislin
Copy link
Author

👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants